@agent-native/core 0.194.0 → 0.195.0-nightly-20260927130129
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/brain/actions/check-builder-embeddings.ts +71 -0
- package/corpus/templates/brain/app/i18n-data.ts +90 -0
- package/corpus/templates/brain/app/routes/sources.tsx +95 -0
- package/corpus/templates/calendar/actions/create-event.ts +264 -32
- package/corpus/templates/calendar/app/i18n/en-US.ts +3 -6
- package/corpus/templates/calendar/app/root.tsx +0 -1
- package/corpus/templates/calendar/changelog/2026-09-27-agent-created-events-show-details-and-open-links.md +6 -0
- package/corpus/templates/calendar/changelog/2026-09-27-calendar-event-cards-retain-meet-and-zoom-links-show-confere.md +6 -0
- package/corpus/templates/calendar/changelog/2026-09-27-calendar-event-cards-show-times-in-the-supplied-offset-or-ca.md +6 -0
- package/corpus/templates/calendar/shared/zoom-add-failed-messages.ts +13 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +144 -13
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +226 -12
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +191 -18
- package/corpus/templates/design/app/pages/DesignEditor.tsx +24 -4
- package/corpus/templates/design/changelog/2026-09-26-live-previews-keep-canvas-keyboard-shortcuts-available-when-.md +6 -0
- package/corpus/templates/design/changelog/2026-09-27-canvas-shortcuts-keep-working-when-a-connected-app-focuses-a.md +6 -0
- package/corpus/templates/design/changelog/2026-09-27-drops-into-plain-frames-now-stack-above-existing-content-whi.md +6 -0
- package/corpus/templates/design/changelog/2026-09-27-layers-dragged-out-of-a-frame-now-stay-above-the-frame.md +6 -0
- package/corpus/templates/design/changelog/2026-09-27-live-previews-keep-canvas-shortcuts-available-after-autofocu.md +6 -0
- package/corpus/templates/mail/actions/apply-ai-filter.ts +8 -20
- package/corpus/templates/mail/actions/create-scheduled-send.ts +16 -3
- package/corpus/templates/mail/actions/manage-automations.ts +54 -3
- package/corpus/templates/mail/actions/manage-draft.ts +11 -23
- package/corpus/templates/mail/actions/manage-gmail-filters.ts +25 -42
- package/corpus/templates/mail/actions/send-email.ts +52 -2
- package/corpus/templates/mail/app/root.tsx +0 -3
- package/corpus/templates/mail/changelog/2026-09-27-scheduled-sends-reject-timestamps-outside-the-supported-date.md +6 -0
- package/corpus/templates/mail/changelog/2026-09-27-show-successful-mail-changes-in-chat.md +6 -0
- package/dist/action-ui.d.ts +19 -0
- package/dist/action-ui.js +68 -0
- package/dist/agent/production-agent.js +9 -1
- package/dist/client/agentkit-chat/action-widget.d.ts +1 -1
- package/dist/client/agentkit-chat/action-widget.js +25 -0
- package/dist/client/agentkit-chat/approval-card.d.ts +7 -0
- package/dist/client/agentkit-chat/approval-card.js +56 -0
- package/dist/client/agentkit-chat/root.js +2 -0
- package/dist/client/chat/action-chat-ui-surface.js +5 -2
- package/dist/client/chat/agent-approval-card.js +4 -3
- package/dist/client/chat/index.d.ts +2 -1
- package/dist/client/chat/index.js +2 -1
- package/dist/client/chat/tool-call-display.js +3 -0
- package/dist/client/chat/tool-render-registry.d.ts +5 -0
- package/dist/client/chat/widgets/ActionCard.d.ts +9 -0
- package/dist/client/chat/widgets/ActionCard.js +5 -0
- package/dist/client/chat/widgets/RecordChangeWidget.d.ts +10 -0
- package/dist/client/chat/widgets/RecordChangeWidget.js +126 -0
- package/dist/client/chat/widgets/builtin-tool-renderers.d.ts +1 -0
- package/dist/client/chat/widgets/builtin-tool-renderers.js +160 -2
- package/dist/client/components/ui/button-classes.d.ts +1 -0
- package/dist/client/components/ui/button-classes.js +1 -0
- package/dist/client/observability/ObservabilityDashboard.js +113 -12
- package/dist/client/observability/ObservabilityReviewSummaryButton.d.ts +1 -1
- package/dist/client/observability/ObservabilityReviewSummaryButton.js +13 -8
- package/dist/client/sse-event-processor.d.ts +1 -0
- package/dist/client/sse-event-processor.js +3 -0
- package/dist/collab/routes.d.ts +2 -2
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/localization/core-messages/ar-SA.js +34 -0
- package/dist/localization/core-messages/de-DE.js +30 -0
- package/dist/localization/core-messages/en-US.d.ts +30 -0
- package/dist/localization/core-messages/en-US.js +30 -0
- package/dist/localization/core-messages/es-ES.js +31 -0
- package/dist/localization/core-messages/fr-FR.js +31 -0
- package/dist/localization/core-messages/hi-IN.js +30 -0
- package/dist/localization/core-messages/ja-JP.js +30 -0
- package/dist/localization/core-messages/ko-KR.js +30 -0
- package/dist/localization/core-messages/pt-BR.js +31 -0
- package/dist/localization/core-messages/zh-CN.js +30 -0
- package/dist/localization/core-messages/zh-TW.js +30 -0
- package/dist/localization/core-messages.d.ts +30 -0
- package/dist/localization/core-messages.js +14 -0
- package/dist/localization/default-messages.d.ts +4 -1
- package/dist/localization/default-messages.js +6 -3
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/reviews.js +26 -14
- package/dist/observability/routes.d.ts +8 -8
- package/dist/observability/store.d.ts +4 -1
- package/dist/observability/store.js +27 -6
- package/dist/observability/types.d.ts +2 -0
- package/dist/progress/routes.d.ts +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/prompts/framework-core-compact.js +1 -1
- package/dist/server/prompts/framework-core.js +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/triggers/actions/manage-automation.d.ts +2 -2
- package/package.json +1 -1
- package/corpus/templates/calendar/app/lib/register-chat-renderers.tsx +0 -295
- package/corpus/templates/mail/app/lib/mail-gmail-filter-confirmation.tsx +0 -77
- package/corpus/templates/mail/app/lib/register-chat-renderers.tsx +0 -54
- package/corpus/templates/mail/app/lib/register-mail-draft-card.tsx +0 -91
|
@@ -140,25 +140,6 @@ export default defineAction({
|
|
|
140
140
|
comment: z.string().max(500).optional(),
|
|
141
141
|
settings: settingsSchema.optional(),
|
|
142
142
|
}),
|
|
143
|
-
chatUI: {
|
|
144
|
-
renderer: "mail.ai-filter-confirmation",
|
|
145
|
-
title: "AI filter result",
|
|
146
|
-
when: (args, result) => {
|
|
147
|
-
if (
|
|
148
|
-
(args.mode !== "filter" && args.mode !== "keep") ||
|
|
149
|
-
!result ||
|
|
150
|
-
typeof result !== "object"
|
|
151
|
-
) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
const changed = (result as Record<string, unknown>).changed;
|
|
155
|
-
return (
|
|
156
|
-
typeof changed === "number" &&
|
|
157
|
-
Number.isSafeInteger(changed) &&
|
|
158
|
-
changed > 0
|
|
159
|
-
);
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
143
|
run: async (args) => {
|
|
163
144
|
const ownerEmail = getRequestUserEmail();
|
|
164
145
|
if (!ownerEmail) throw new Error("no authenticated user");
|
|
@@ -320,10 +301,17 @@ export default defineAction({
|
|
|
320
301
|
);
|
|
321
302
|
await writeAppState("refresh-signal", { ts: Date.now() });
|
|
322
303
|
|
|
304
|
+
const changed = succeededTargets.length;
|
|
323
305
|
return {
|
|
324
|
-
changed
|
|
306
|
+
changed,
|
|
325
307
|
failures,
|
|
326
308
|
state: await getAiFilterState(ownerEmail),
|
|
309
|
+
change: {
|
|
310
|
+
verb: "updated",
|
|
311
|
+
kind: "mail-filter",
|
|
312
|
+
title: action === "filter" ? "Filtered email" : "Kept email",
|
|
313
|
+
detail: String(changed),
|
|
314
|
+
},
|
|
327
315
|
};
|
|
328
316
|
},
|
|
329
317
|
});
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
fail,
|
|
4
4
|
type ActionRunContext,
|
|
5
5
|
} from "@agent-native/core/action";
|
|
6
|
-
import { getRequestUserEmail } from "@agent-native/core/server";
|
|
6
|
+
import { buildDeepLink, getRequestUserEmail } from "@agent-native/core/server";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
|
|
9
9
|
import { requiresEmailSendApproval } from "../server/lib/automation-settings.js";
|
|
@@ -68,7 +68,11 @@ export default defineAction({
|
|
|
68
68
|
run: async (args, ctx) => {
|
|
69
69
|
const ownerEmail = getRequestUserEmail();
|
|
70
70
|
if (!ownerEmail) fail("Unauthenticated", { errorCode: "unauthenticated" });
|
|
71
|
-
if (
|
|
71
|
+
if (
|
|
72
|
+
!Number.isFinite(args.runAt) ||
|
|
73
|
+
!Number.isFinite(new Date(args.runAt).getTime()) ||
|
|
74
|
+
args.runAt <= Date.now()
|
|
75
|
+
) {
|
|
72
76
|
fail("runAt must be a future timestamp", {
|
|
73
77
|
errorCode: "invalid_run_at",
|
|
74
78
|
});
|
|
@@ -143,7 +147,7 @@ export default defineAction({
|
|
|
143
147
|
);
|
|
144
148
|
const persistedPayload = { ...payload, accountEmail };
|
|
145
149
|
|
|
146
|
-
|
|
150
|
+
const job = await createScheduledJobRecord({
|
|
147
151
|
type: "send_later",
|
|
148
152
|
ownerEmail,
|
|
149
153
|
emailId: args.emailId ?? null,
|
|
@@ -152,5 +156,14 @@ export default defineAction({
|
|
|
152
156
|
payload: persistedPayload,
|
|
153
157
|
runAt: args.runAt,
|
|
154
158
|
});
|
|
159
|
+
return {
|
|
160
|
+
...job,
|
|
161
|
+
change: {
|
|
162
|
+
verb: "scheduled",
|
|
163
|
+
kind: "scheduled-email",
|
|
164
|
+
title: new Date(job.runAt).toISOString(),
|
|
165
|
+
url: buildDeepLink({ app: "mail", view: "scheduled" }),
|
|
166
|
+
},
|
|
167
|
+
};
|
|
155
168
|
},
|
|
156
169
|
});
|
|
@@ -90,6 +90,33 @@ function ruleResult(
|
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
function ruleChange(
|
|
94
|
+
verb: "created" | "updated" | "enabled" | "disabled",
|
|
95
|
+
rule: AutomationRule,
|
|
96
|
+
) {
|
|
97
|
+
const title = rule.name.trim() || rule.condition.trim() || rule.id;
|
|
98
|
+
const detail = rule.condition.trim();
|
|
99
|
+
return {
|
|
100
|
+
change: {
|
|
101
|
+
verb,
|
|
102
|
+
kind: "mail-rule",
|
|
103
|
+
title: title.slice(0, 180),
|
|
104
|
+
...(detail && detail !== title ? { detail: detail.slice(0, 500) } : {}),
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function ruleChanged(before: AutomationRule, after: AutomationRule): boolean {
|
|
110
|
+
return (
|
|
111
|
+
before.name !== after.name ||
|
|
112
|
+
before.condition !== after.condition ||
|
|
113
|
+
JSON.stringify(before.actions) !== JSON.stringify(after.actions) ||
|
|
114
|
+
before.enabled !== after.enabled ||
|
|
115
|
+
before.domain !== after.domain ||
|
|
116
|
+
before.kind !== after.kind
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
93
120
|
async function startRecentBackfill(ownerEmail: string, rule: AutomationRule) {
|
|
94
121
|
if (!rule.enabled) return { backfillStatus: "not-started-disabled" };
|
|
95
122
|
|
|
@@ -214,7 +241,10 @@ export const createManageEmailRulesAction = (agentTool: boolean) =>
|
|
|
214
241
|
kind === "ai-filter"
|
|
215
242
|
? await startRecentBackfill(ownerEmail, rule)
|
|
216
243
|
: { backfillStatus: "not-applicable" };
|
|
217
|
-
return ruleResult(rule, "create",
|
|
244
|
+
return ruleResult(rule, "create", {
|
|
245
|
+
...backfill,
|
|
246
|
+
...(agentTool ? ruleChange("created", rule) : {}),
|
|
247
|
+
});
|
|
218
248
|
}
|
|
219
249
|
|
|
220
250
|
case "update": {
|
|
@@ -264,7 +294,12 @@ export const createManageEmailRulesAction = (agentTool: boolean) =>
|
|
|
264
294
|
rule.domain === "mail" && rule.kind === "ai-filter"
|
|
265
295
|
? await startRecentBackfill(ownerEmail, rule)
|
|
266
296
|
: { backfillStatus: "not-applicable" };
|
|
267
|
-
return ruleResult(rule, "update",
|
|
297
|
+
return ruleResult(rule, "update", {
|
|
298
|
+
...backfill,
|
|
299
|
+
...(agentTool && existing && ruleChanged(existing, rule)
|
|
300
|
+
? ruleChange("updated", rule)
|
|
301
|
+
: {}),
|
|
302
|
+
});
|
|
268
303
|
}
|
|
269
304
|
|
|
270
305
|
case "delete": {
|
|
@@ -283,6 +318,11 @@ export const createManageEmailRulesAction = (agentTool: boolean) =>
|
|
|
283
318
|
case "enable":
|
|
284
319
|
case "disable": {
|
|
285
320
|
if (!args.id) throw new Error(`--id is required for ${args.action}`);
|
|
321
|
+
const existing = agentTool
|
|
322
|
+
? (await listAutomationRules(ownerEmail)).find(
|
|
323
|
+
(rule) => rule.id === args.id,
|
|
324
|
+
)
|
|
325
|
+
: undefined;
|
|
286
326
|
const patch = { enabled: args.action === "enable" };
|
|
287
327
|
const rule = await updateAutomationRule(ownerEmail, args.id, patch);
|
|
288
328
|
const backfill =
|
|
@@ -291,7 +331,18 @@ export const createManageEmailRulesAction = (agentTool: boolean) =>
|
|
|
291
331
|
rule.kind === "ai-filter"
|
|
292
332
|
? await startRecentBackfill(ownerEmail, rule)
|
|
293
333
|
: { backfillStatus: "not-applicable" };
|
|
294
|
-
return ruleResult(rule, args.action,
|
|
334
|
+
return ruleResult(rule, args.action, {
|
|
335
|
+
...backfill,
|
|
336
|
+
...(agentTool &&
|
|
337
|
+
existing &&
|
|
338
|
+
existing.enabled !== rule.enabled &&
|
|
339
|
+
rule.enabled === (args.action === "enable")
|
|
340
|
+
? ruleChange(
|
|
341
|
+
args.action === "enable" ? "enabled" : "disabled",
|
|
342
|
+
rule,
|
|
343
|
+
)
|
|
344
|
+
: {}),
|
|
345
|
+
});
|
|
295
346
|
}
|
|
296
347
|
|
|
297
348
|
default:
|
|
@@ -145,28 +145,6 @@ export default defineAction({
|
|
|
145
145
|
"delete before a matching create - to draft a reply, first call with " +
|
|
146
146
|
"action=create, mode=reply, replyToId, to, subject, body.",
|
|
147
147
|
schema: manageDraftSchema,
|
|
148
|
-
chatUI: {
|
|
149
|
-
renderer: "mail.draft-created",
|
|
150
|
-
when: (args, result) => {
|
|
151
|
-
if (args.action !== "create" || !result || typeof result !== "object") {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
const record = result as Record<string, unknown>;
|
|
155
|
-
return (
|
|
156
|
-
typeof record.deepLink === "string" &&
|
|
157
|
-
Boolean(record.draft) &&
|
|
158
|
-
typeof record.draft === "object"
|
|
159
|
-
);
|
|
160
|
-
},
|
|
161
|
-
projectResult: (_args, result) => {
|
|
162
|
-
const record = result as Record<string, unknown>;
|
|
163
|
-
const draft = record.draft as Record<string, unknown>;
|
|
164
|
-
return {
|
|
165
|
-
draft: { subject: draft.subject, to: draft.to },
|
|
166
|
-
deepLink: record.deepLink,
|
|
167
|
-
};
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
148
|
mcpApp: {
|
|
171
149
|
compactCatalog: true,
|
|
172
150
|
resource: embedApp({
|
|
@@ -321,11 +299,21 @@ export default defineAction({
|
|
|
321
299
|
},
|
|
322
300
|
ctx,
|
|
323
301
|
);
|
|
302
|
+
const deepLink = composeDeepLink(draft);
|
|
303
|
+
const subject = draft.subject.trim();
|
|
304
|
+
const recipient = draft.to.trim();
|
|
324
305
|
return {
|
|
325
306
|
id,
|
|
326
307
|
draft,
|
|
327
|
-
deepLink
|
|
308
|
+
deepLink,
|
|
328
309
|
message: `Created draft ${id}`,
|
|
310
|
+
change: {
|
|
311
|
+
verb: "created",
|
|
312
|
+
kind: "email-draft",
|
|
313
|
+
title: (subject || recipient || id).slice(0, 180),
|
|
314
|
+
...(subject && recipient ? { detail: recipient.slice(0, 500) } : {}),
|
|
315
|
+
url: deepLink,
|
|
316
|
+
},
|
|
329
317
|
};
|
|
330
318
|
}
|
|
331
319
|
|
|
@@ -156,6 +156,13 @@ const SYSTEM_LABEL_NAMES: Record<string, string> = {
|
|
|
156
156
|
TRASH: "Trash",
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
+
function gmailFiltersUrl(accountEmail: string): string {
|
|
160
|
+
const url = new URL("https://mail.google.com/mail/");
|
|
161
|
+
url.searchParams.set("authuser", accountEmail);
|
|
162
|
+
url.hash = "settings/filters";
|
|
163
|
+
return url.toString();
|
|
164
|
+
}
|
|
165
|
+
|
|
159
166
|
const CRITERIA_KEYS = [
|
|
160
167
|
"from",
|
|
161
168
|
"to",
|
|
@@ -565,46 +572,6 @@ export default defineAction({
|
|
|
565
572
|
description:
|
|
566
573
|
"List, create, edit, or delete native Gmail filters. Use this for simple deterministic Gmail rules, such as auto-archive from a sender or query, instead of AI automations.",
|
|
567
574
|
schema,
|
|
568
|
-
chatUI: {
|
|
569
|
-
renderer: "mail.gmail-filter-confirmation",
|
|
570
|
-
when: (args, result) => {
|
|
571
|
-
if (
|
|
572
|
-
(args.operation !== "create" && args.operation !== "replace") ||
|
|
573
|
-
!result ||
|
|
574
|
-
typeof result !== "object"
|
|
575
|
-
) {
|
|
576
|
-
return false;
|
|
577
|
-
}
|
|
578
|
-
const record = result as Record<string, unknown>;
|
|
579
|
-
const filter = record.filter;
|
|
580
|
-
return (
|
|
581
|
-
record.ok === true &&
|
|
582
|
-
typeof record.message === "string" &&
|
|
583
|
-
typeof record.accountEmail === "string" &&
|
|
584
|
-
Boolean(filter) &&
|
|
585
|
-
typeof filter === "object" &&
|
|
586
|
-
!Array.isArray(filter) &&
|
|
587
|
-
typeof (filter as Record<string, unknown>).id === "string" &&
|
|
588
|
-
typeof (filter as Record<string, unknown>).criteriaSummary ===
|
|
589
|
-
"string" &&
|
|
590
|
-
typeof (filter as Record<string, unknown>).actionSummary === "string"
|
|
591
|
-
);
|
|
592
|
-
},
|
|
593
|
-
projectResult: (_args, result) => {
|
|
594
|
-
const record = result as Record<string, unknown>;
|
|
595
|
-
const filter = record.filter as Record<string, unknown>;
|
|
596
|
-
return {
|
|
597
|
-
ok: record.ok,
|
|
598
|
-
message: record.message,
|
|
599
|
-
accountEmail: record.accountEmail,
|
|
600
|
-
filter: {
|
|
601
|
-
id: filter.id,
|
|
602
|
-
criteriaSummary: filter.criteriaSummary,
|
|
603
|
-
actionSummary: filter.actionSummary,
|
|
604
|
-
},
|
|
605
|
-
};
|
|
606
|
-
},
|
|
607
|
-
},
|
|
608
575
|
run: async (args) => {
|
|
609
576
|
const accounts = await allAccounts();
|
|
610
577
|
|
|
@@ -680,11 +647,19 @@ export default defineAction({
|
|
|
680
647
|
action,
|
|
681
648
|
});
|
|
682
649
|
await signalRefresh();
|
|
650
|
+
const filter = enrichFilter(account.email, created, labels);
|
|
683
651
|
return {
|
|
684
652
|
ok: true,
|
|
685
653
|
message: `Created Gmail filter ${created.id} in ${account.email}.`,
|
|
686
654
|
accountEmail: account.email,
|
|
687
|
-
filter
|
|
655
|
+
filter,
|
|
656
|
+
change: {
|
|
657
|
+
verb: "created",
|
|
658
|
+
kind: "gmail-filter",
|
|
659
|
+
title: filter.criteriaSummary.slice(0, 180),
|
|
660
|
+
detail: filter.actionSummary.slice(0, 500),
|
|
661
|
+
url: gmailFiltersUrl(account.email),
|
|
662
|
+
},
|
|
688
663
|
};
|
|
689
664
|
}
|
|
690
665
|
|
|
@@ -729,12 +704,20 @@ export default defineAction({
|
|
|
729
704
|
await gmailDeleteFilter(target.account.accessToken, args.id);
|
|
730
705
|
await signalRefresh();
|
|
731
706
|
|
|
707
|
+
const filter = enrichFilter(target.account.email, created, labels);
|
|
732
708
|
return {
|
|
733
709
|
ok: true,
|
|
734
710
|
message: `Replaced Gmail filter ${args.id} with ${created.id} in ${target.account.email}.`,
|
|
735
711
|
accountEmail: target.account.email,
|
|
736
712
|
deletedId: args.id,
|
|
737
|
-
filter
|
|
713
|
+
filter,
|
|
714
|
+
change: {
|
|
715
|
+
verb: "updated",
|
|
716
|
+
kind: "gmail-filter",
|
|
717
|
+
title: filter.criteriaSummary.slice(0, 180),
|
|
718
|
+
detail: filter.actionSummary.slice(0, 500),
|
|
719
|
+
url: gmailFiltersUrl(target.account.email),
|
|
720
|
+
},
|
|
738
721
|
};
|
|
739
722
|
}
|
|
740
723
|
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core/action";
|
|
2
2
|
import type { ActionRunContext } from "@agent-native/core/action";
|
|
3
|
+
import { ACTION_CHAT_UI_RECORD_CHANGE_RENDERER } from "@agent-native/core/action-ui";
|
|
3
4
|
import { writeAppState } from "@agent-native/core/application-state";
|
|
4
5
|
import { emit } from "@agent-native/core/event-bus";
|
|
5
6
|
import { setOAuthDisplayName } from "@agent-native/core/oauth-tokens";
|
|
6
|
-
import {
|
|
7
|
-
|
|
7
|
+
import {
|
|
8
|
+
buildDeepLink,
|
|
9
|
+
getAppProductionUrl,
|
|
10
|
+
getRequestUserEmail,
|
|
11
|
+
} from "@agent-native/core/server";
|
|
8
12
|
import { getUserSetting } from "@agent-native/core/settings";
|
|
9
13
|
import { track } from "@agent-native/core/tracking";
|
|
10
14
|
import { nanoid } from "nanoid";
|
|
@@ -98,6 +102,28 @@ function countRecipients(...values: Array<string | undefined>): number {
|
|
|
98
102
|
.filter((value) => value.trim()).length;
|
|
99
103
|
}
|
|
100
104
|
|
|
105
|
+
function sentMessageId(result: unknown): string | undefined {
|
|
106
|
+
if (typeof result !== "string") return undefined;
|
|
107
|
+
const match = result.match(/^Email sent successfully \(id: ([^)]+)\)$/);
|
|
108
|
+
if (match?.[1]) return match[1];
|
|
109
|
+
try {
|
|
110
|
+
const localResult: unknown = JSON.parse(result);
|
|
111
|
+
if (
|
|
112
|
+
localResult &&
|
|
113
|
+
typeof localResult === "object" &&
|
|
114
|
+
!Array.isArray(localResult) &&
|
|
115
|
+
(localResult as Record<string, unknown>).isSent === true &&
|
|
116
|
+
typeof (localResult as Record<string, unknown>).id === "string"
|
|
117
|
+
) {
|
|
118
|
+
return (localResult as Record<string, string>).id;
|
|
119
|
+
}
|
|
120
|
+
} catch {
|
|
121
|
+
// coercion-ok: plain Gmail result text has no local message id to project.
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
101
127
|
const attachmentSchema = z.object({
|
|
102
128
|
filename: z
|
|
103
129
|
.string()
|
|
@@ -144,6 +170,30 @@ export default defineAction({
|
|
|
144
170
|
"Files to attach. Each entry must reference a previously-uploaded file by its server-side `filename`. The upload must have been created via the media-upload endpoint before calling this action.",
|
|
145
171
|
),
|
|
146
172
|
}),
|
|
173
|
+
chatUI: {
|
|
174
|
+
renderer: ACTION_CHAT_UI_RECORD_CHANGE_RENDERER,
|
|
175
|
+
when: (_args, result) => Boolean(sentMessageId(result)),
|
|
176
|
+
projectResult: (args, result) => {
|
|
177
|
+
const messageId = sentMessageId(result);
|
|
178
|
+
const subject =
|
|
179
|
+
typeof args.subject === "string" ? args.subject.trim() : "";
|
|
180
|
+
const to = typeof args.to === "string" ? args.to.trim() : "";
|
|
181
|
+
if (!messageId || (!subject && !to)) return null;
|
|
182
|
+
return {
|
|
183
|
+
change: {
|
|
184
|
+
verb: "sent",
|
|
185
|
+
kind: "email",
|
|
186
|
+
title: (subject || to).slice(0, 180),
|
|
187
|
+
...(to ? { detail: to.slice(0, 500) } : {}),
|
|
188
|
+
url: buildDeepLink({
|
|
189
|
+
app: "mail",
|
|
190
|
+
view: "sent",
|
|
191
|
+
params: { messageId },
|
|
192
|
+
}),
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
},
|
|
147
197
|
needsApproval: (_args, ctx?: ActionRunContext) =>
|
|
148
198
|
requiresEmailSendApproval(ctx),
|
|
149
199
|
run: async (args, ctx) => {
|
|
@@ -48,9 +48,6 @@ import {
|
|
|
48
48
|
} from "@/lib/integration-status";
|
|
49
49
|
import { shouldInvalidateMailQueryForActionEvent } from "@/lib/sync-invalidation";
|
|
50
50
|
import { TAB_ID } from "@/lib/tab-id";
|
|
51
|
-
import "@/lib/register-chat-renderers";
|
|
52
|
-
import "@/lib/mail-gmail-filter-confirmation";
|
|
53
|
-
import "@/lib/register-mail-draft-card";
|
|
54
51
|
|
|
55
52
|
import { i18nCatalog } from "./i18n";
|
|
56
53
|
|
package/dist/action-ui.d.ts
CHANGED
|
@@ -3,7 +3,25 @@ export declare const ACTION_CHAT_UI_DATA_CHART_RENDERER = "core.data-chart";
|
|
|
3
3
|
export declare const ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER = "core.data-insights";
|
|
4
4
|
export declare const ACTION_CHAT_UI_DATA_WIDGET_RENDERER = "core.data-widget";
|
|
5
5
|
export declare const ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER = "core.inline-extension";
|
|
6
|
+
export declare const ACTION_CHAT_UI_RECORD_CHANGE_RENDERER = "core.record-change";
|
|
6
7
|
export declare const ACTION_CHAT_UI_WORKSPACE_FILE_RENDERER = "core.workspace-file";
|
|
8
|
+
export declare const ACTION_CHANGE_VERBS: readonly ["created", "updated", "deleted", "sent", "scheduled", "enabled", "disabled"];
|
|
9
|
+
export type ActionChangeVerb = (typeof ACTION_CHANGE_VERBS)[number];
|
|
10
|
+
export interface ActionChangeUndo {
|
|
11
|
+
action: string;
|
|
12
|
+
args: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface ActionChange {
|
|
15
|
+
verb: ActionChangeVerb;
|
|
16
|
+
kind: string;
|
|
17
|
+
title: string;
|
|
18
|
+
detail?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
undo?: ActionChangeUndo;
|
|
21
|
+
}
|
|
22
|
+
export interface ActionChangeResult {
|
|
23
|
+
change: ActionChange;
|
|
24
|
+
}
|
|
7
25
|
export interface ActionChatUIConfig {
|
|
8
26
|
renderer: string;
|
|
9
27
|
title?: string;
|
|
@@ -13,4 +31,5 @@ export interface ActionChatUIConfig {
|
|
|
13
31
|
/** Return the small result needed by the renderer and interrupted-run recovery. */
|
|
14
32
|
projectResult?: (args: Record<string, unknown>, result: unknown) => unknown;
|
|
15
33
|
}
|
|
34
|
+
export declare function normalizeActionChangeResult(value: unknown): ActionChangeResult | null;
|
|
16
35
|
export declare function normalizeActionChatUIConfig(value: unknown): ActionChatUIConfig | undefined;
|
package/dist/action-ui.js
CHANGED
|
@@ -3,7 +3,75 @@ export const ACTION_CHAT_UI_DATA_CHART_RENDERER = "core.data-chart";
|
|
|
3
3
|
export const ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER = "core.data-insights";
|
|
4
4
|
export const ACTION_CHAT_UI_DATA_WIDGET_RENDERER = "core.data-widget";
|
|
5
5
|
export const ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER = "core.inline-extension";
|
|
6
|
+
export const ACTION_CHAT_UI_RECORD_CHANGE_RENDERER = "core.record-change";
|
|
6
7
|
export const ACTION_CHAT_UI_WORKSPACE_FILE_RENDERER = "core.workspace-file";
|
|
8
|
+
export const ACTION_CHANGE_VERBS = [
|
|
9
|
+
"created",
|
|
10
|
+
"updated",
|
|
11
|
+
"deleted",
|
|
12
|
+
"sent",
|
|
13
|
+
"scheduled",
|
|
14
|
+
"enabled",
|
|
15
|
+
"disabled",
|
|
16
|
+
];
|
|
17
|
+
export function normalizeActionChangeResult(value) {
|
|
18
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const change = value.change;
|
|
22
|
+
if (!change || typeof change !== "object" || Array.isArray(change)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const record = change;
|
|
26
|
+
if (typeof record.verb !== "string" ||
|
|
27
|
+
!ACTION_CHANGE_VERBS.includes(record.verb) ||
|
|
28
|
+
typeof record.kind !== "string" ||
|
|
29
|
+
!/^[a-z][a-z0-9-]*$/.test(record.kind) ||
|
|
30
|
+
typeof record.title !== "string" ||
|
|
31
|
+
!record.title.trim() ||
|
|
32
|
+
record.title.length > 180) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if ((record.detail !== undefined && typeof record.detail !== "string") ||
|
|
36
|
+
(typeof record.detail === "string" && record.detail.length > 500) ||
|
|
37
|
+
(record.url !== undefined && typeof record.url !== "string")) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
let undo;
|
|
41
|
+
if (record.undo !== undefined) {
|
|
42
|
+
if (!record.undo ||
|
|
43
|
+
typeof record.undo !== "object" ||
|
|
44
|
+
Array.isArray(record.undo)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const candidate = record.undo;
|
|
48
|
+
if (typeof candidate.action !== "string" ||
|
|
49
|
+
!/^[a-z][a-z0-9-]*$/.test(candidate.action) ||
|
|
50
|
+
!candidate.args ||
|
|
51
|
+
typeof candidate.args !== "object" ||
|
|
52
|
+
Array.isArray(candidate.args)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
undo = {
|
|
56
|
+
action: candidate.action,
|
|
57
|
+
args: candidate.args,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
change: {
|
|
62
|
+
verb: record.verb,
|
|
63
|
+
kind: record.kind.trim(),
|
|
64
|
+
title: record.title.trim(),
|
|
65
|
+
...(typeof record.detail === "string" && record.detail.trim()
|
|
66
|
+
? { detail: record.detail.trim() }
|
|
67
|
+
: {}),
|
|
68
|
+
...(typeof record.url === "string" && record.url.trim()
|
|
69
|
+
? { url: record.url.trim() }
|
|
70
|
+
: {}),
|
|
71
|
+
...(undo ? { undo } : {}),
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
7
75
|
export function normalizeActionChatUIConfig(value) {
|
|
8
76
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
9
77
|
return undefined;
|
|
@@ -3,6 +3,7 @@ import Ajv from "ajv";
|
|
|
3
3
|
import { defineEventHandler, getHeader, setResponseHeader, setResponseStatus, getMethod, } from "h3";
|
|
4
4
|
import "../authorization/check-action.js";
|
|
5
5
|
import { parseA2AAgentActivityPart } from "../a2a/activity.js";
|
|
6
|
+
import { ACTION_CHAT_UI_RECORD_CHANGE_RENDERER, normalizeActionChangeResult, } from "../action-ui.js";
|
|
6
7
|
import { AgentConnectionRequiredError, describeToolParameterSignature, isActionContractError, isActionHiddenFromEveryAgentSurface, isAgentActionStopError, isAgentConnectionRequiredError, stripUnsupportedSchemaKeywords, } from "../action.js";
|
|
7
8
|
import { getAppConfig } from "../app-config/index.js";
|
|
8
9
|
import { MAX_BACKGROUND_RUN_CONTINUATIONS, MAX_CONSECUTIVE_NO_PROGRESS_CONTINUATIONS, MAX_TURN_WALL_CLOCK_MS, } from "../app-config/run-lifecycle-invariants.js";
|
|
@@ -496,7 +497,14 @@ export async function getOwnerAnthropicApiKey(ownerEmail) {
|
|
|
496
497
|
return getOwnerApiKey("anthropic", ownerEmail);
|
|
497
498
|
}
|
|
498
499
|
function actionChatUIForResult(actionName, actionEntry, args, result, isError, storedWidgetResult = false) {
|
|
499
|
-
const chatUI = actionEntry.chatUI
|
|
500
|
+
const chatUI = actionEntry.chatUI ??
|
|
501
|
+
(normalizeActionChangeResult(result)
|
|
502
|
+
? {
|
|
503
|
+
renderer: ACTION_CHAT_UI_RECORD_CHANGE_RENDERER,
|
|
504
|
+
when: (_args, value) => normalizeActionChangeResult(value) !== null,
|
|
505
|
+
projectResult: (_args, value) => normalizeActionChangeResult(value),
|
|
506
|
+
}
|
|
507
|
+
: undefined);
|
|
500
508
|
if (!chatUI || isError)
|
|
501
509
|
return undefined;
|
|
502
510
|
if (!storedWidgetResult && chatUI.when) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AgentWidget } from "@agent-native/agentkit/protocol";
|
|
2
2
|
import { type AgentKitRenderProps } from "@agent-native/agentkit/react/context";
|
|
3
|
-
export declare function AgentKitActionWidget({ value: widget, threadId, }: AgentKitRenderProps<AgentWidget>): import("react").JSX.Element;
|
|
3
|
+
export declare function AgentKitActionWidget({ value: widget, threadId, }: AgentKitRenderProps<AgentWidget>): import("react").JSX.Element | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { AgentWidgetView } from "@agent-native/agentkit/react/components";
|
|
3
3
|
import { useAgentThread, } from "@agent-native/agentkit/react/context";
|
|
4
|
+
import { ACTION_CHAT_UI_RECORD_CHANGE_RENDERER, normalizeActionChangeResult, } from "../../action-ui.js";
|
|
4
5
|
import { ActionChatUiSurface } from "../chat/action-chat-ui-surface.js";
|
|
5
6
|
import { resolveToolRenderer } from "../chat/tool-render-registry.js";
|
|
6
7
|
import { isBuiltinConnectRequiredResult, isBuiltinDataWidgetActionRenderer, isBuiltinWorkspaceFileResult, resolveBuiltinActionChatRenderer, resolveBuiltinFallbackToolRenderer, } from "../chat/widgets/builtin-tool-renderers.js";
|
|
@@ -17,6 +18,28 @@ export function AgentKitActionWidget({ value: widget, threadId, }) {
|
|
|
17
18
|
if (!tool)
|
|
18
19
|
return _jsx(AgentWidgetView, { value: widget, threadId: threadId });
|
|
19
20
|
const resultJson = tool.output;
|
|
21
|
+
const messageId = thread.widgetMessageIds[widget.id];
|
|
22
|
+
const attachedChangeWidgets = widget.kind === ACTION_CHAT_UI_RECORD_CHANGE_RENDERER && messageId
|
|
23
|
+
? Object.values(thread.widgets).filter((candidate) => candidate.kind === ACTION_CHAT_UI_RECORD_CHANGE_RENDERER &&
|
|
24
|
+
thread.widgetMessageIds[candidate.id] === messageId)
|
|
25
|
+
: [];
|
|
26
|
+
const relatedResults = attachedChangeWidgets
|
|
27
|
+
.map((candidate) => {
|
|
28
|
+
const candidateData = asRecord(candidate.data);
|
|
29
|
+
const candidateToolCallId = candidateData?.toolCallId;
|
|
30
|
+
const candidateTool = typeof candidateToolCallId === "string"
|
|
31
|
+
? thread.tools[candidateToolCallId]
|
|
32
|
+
: null;
|
|
33
|
+
return candidateTool?.status !== "completed" ||
|
|
34
|
+
candidateTool.output === undefined
|
|
35
|
+
? null
|
|
36
|
+
: { widgetId: candidate.id, result: candidateTool.output };
|
|
37
|
+
})
|
|
38
|
+
.filter((entry) => entry !== null && normalizeActionChangeResult(entry.result) !== null);
|
|
39
|
+
const primaryChangeWidgetId = relatedResults[0]?.widgetId ?? attachedChangeWidgets[0]?.id;
|
|
40
|
+
if (attachedChangeWidgets.length > 1 && primaryChangeWidgetId !== widget.id) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
20
43
|
const context = {
|
|
21
44
|
toolName: tool.name,
|
|
22
45
|
args: asRecord(tool.input) ?? {},
|
|
@@ -26,6 +49,8 @@ export function AgentKitActionWidget({ value: widget, threadId, }) {
|
|
|
26
49
|
? undefined
|
|
27
50
|
: JSON.stringify(tool.output),
|
|
28
51
|
resultJson,
|
|
52
|
+
...(relatedResults.length > 1 ? { relatedResults } : {}),
|
|
53
|
+
widgetId: widget.id,
|
|
29
54
|
isRunning: tool.status === "running",
|
|
30
55
|
chatUI: {
|
|
31
56
|
renderer: widget.kind,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AgentApprovalRequest } from "@agent-native/agentkit/protocol";
|
|
2
|
+
import { type AgentKitRenderProps } from "@agent-native/agentkit/react/context";
|
|
3
|
+
type ApprovalSlotProps = AgentKitRenderProps<AgentApprovalRequest> & {
|
|
4
|
+
runId: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function CoreAgentKitApproval(props: ApprovalSlotProps): import("react").JSX.Element;
|
|
7
|
+
export {};
|