@agent-native/core 0.91.2 → 0.92.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 +2 -2
- package/corpus/core/CHANGELOG.md +17 -0
- package/corpus/core/docs/content/faq.mdx +17 -0
- package/corpus/core/docs/content/notifications.mdx +12 -6
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/production-agent.ts +140 -46
- package/corpus/core/src/agent/tool-search.ts +71 -4
- package/corpus/core/src/cli/index.ts +20 -0
- package/corpus/core/src/cli/upgrade.ts +798 -0
- package/corpus/core/src/client/AssistantChat.tsx +1 -1
- package/corpus/core/src/client/HighlightedCodeBlock.tsx +20 -3
- package/corpus/core/src/client/agent-chat-adapter.ts +31 -6
- package/corpus/core/src/client/chat/message-components.tsx +85 -8
- package/corpus/core/src/client/chat/tool-call-display.tsx +355 -144
- package/corpus/core/src/client/code-agent-chat-adapter.ts +2 -9
- package/corpus/core/src/client/session-replay.ts +3 -97
- package/corpus/core/src/client/settings/SettingsPanel.tsx +533 -389
- package/corpus/core/src/client/settings/SettingsSection.tsx +154 -17
- package/corpus/core/src/client/sse-event-processor.ts +29 -2
- package/corpus/core/src/extensions/actions.ts +113 -5
- package/corpus/core/src/notifications/channels.ts +88 -25
- package/corpus/core/src/notifications/registry.ts +17 -3
- package/corpus/core/src/notifications/types.ts +4 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +7 -3
- package/corpus/core/src/server/request-context.ts +7 -0
- package/corpus/core/src/styles/agent-conversation.css +1 -1
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/default/AGENTS.md +10 -3
- package/corpus/core/src/templates/default/package.json +2 -1
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/headless/AGENTS.md +9 -3
- package/corpus/core/src/templates/headless/package.json +1 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/workspace-root/AGENTS.md +10 -4
- package/corpus/core/src/templates/workspace-root/package.json +1 -0
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/analytics/.agents/skills/session-replay/SKILL.md +5 -6
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/analytics/AGENTS.md +7 -5
- package/corpus/templates/analytics/actions/save-monitor.ts +14 -0
- package/corpus/templates/analytics/app/components/dashboard/DataTable.tsx +41 -6
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +122 -11
- package/corpus/templates/analytics/app/pages/monitoring/MonitoringPage.tsx +8 -2
- package/corpus/templates/analytics/app/pages/monitoring/uptime/MonitorFormPage.tsx +151 -32
- package/corpus/templates/analytics/app/pages/monitoring/uptime/i18n.ts +17 -2
- package/corpus/templates/analytics/app/pages/monitoring/uptime/types.ts +4 -0
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +54 -190
- package/corpus/templates/analytics/changelog/2026-07-08-dashboard-tables-keep-their-size-while-loading.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-monitoring-uptime-and-errors-tabs-now-clearly-show-which-view-is-active.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-session-replay-uses-stock-rrweb-sizing-again-so-recorded.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-sidebar-dashboard-menus-now-open-above-the-dashboard-canvas.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-uptime-alerting-clarifies-in-app-inbox-vs-email-and-lets-you-paste-slack-or-webhook-urls-per-monitor.md +6 -0
- package/corpus/templates/analytics/docs/uptime-monitoring.md +13 -11
- package/corpus/templates/analytics/server/db/schema-monitoring.ts +4 -0
- package/corpus/templates/analytics/server/lib/uptime-monitors.ts +60 -12
- package/corpus/templates/analytics/server/plugins/db.ts +10 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/clips/changelog/2026-07-08-desktop-meeting-notes-stay-active-from-tray-and-shortcut-controls.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-desktop-meeting-popovers-can-start-notes-and-join-the-meetin.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-meeting-notes-keep-their-recording-state-when-the-desktop.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-meeting-reminder-dropdowns-now-expand-fully-instead-of-being.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +123 -3
- package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +15 -1
- package/corpus/templates/clips/desktop/src/overlays/meeting-notification.tsx +23 -0
- package/corpus/templates/clips/desktop/src/styles.css +23 -1
- package/corpus/templates/clips/desktop/src-tauri/src/adhoc_meetings_watcher.rs +1 -3
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +40 -6
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +4 -2
- package/corpus/templates/clips/desktop/src-tauri/src/meetings_watcher.rs +3 -5
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +23 -19
- package/corpus/templates/clips/desktop/src-tauri/src/shortcuts.rs +3 -3
- package/corpus/templates/clips/desktop/src-tauri/src/silence_detector.rs +0 -1
- package/corpus/templates/clips/desktop/src-tauri/src/state.rs +5 -0
- package/corpus/templates/clips/desktop/src-tauri/src/tray.rs +18 -6
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/content/actions/_batch-utils.ts +8 -0
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +7 -5
- package/corpus/templates/content/actions/_database-source-utils.ts +776 -319
- package/corpus/templates/content/actions/_database-utils.ts +6 -1
- package/corpus/templates/content/actions/_property-utils.ts +168 -0
- package/corpus/templates/content/actions/add-content-database-source-field-property.ts +19 -12
- package/corpus/templates/content/actions/bind-content-database-source-field.ts +19 -12
- package/corpus/templates/content/actions/delete-document.ts +9 -13
- package/corpus/templates/content/actions/refresh-content-database-source.ts +5 -5
- package/corpus/templates/content/app/components/editor/body-hydration.ts +35 -11
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +47 -5
- package/corpus/templates/content/app/hooks/use-documents.ts +8 -2
- package/corpus/templates/content/changelog/2026-07-08-builder-source-sync-now-completes-reliably-on-hosted-databases.md +6 -0
- package/corpus/templates/content/changelog/2026-07-08-fixed-builder-database-sync-so-large-sources-continue-past-t.md +6 -0
- package/corpus/templates/content/server/plugins/db.ts +19 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/videos/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/voice/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/agent/production-agent.d.ts +5 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +112 -42
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/tool-search.d.ts +2 -0
- package/dist/agent/tool-search.d.ts.map +1 -1
- package/dist/agent/tool-search.js +60 -4
- package/dist/agent/tool-search.js.map +1 -1
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/upgrade.d.ts +100 -0
- package/dist/cli/upgrade.d.ts.map +1 -0
- package/dist/cli/upgrade.js +678 -0
- package/dist/cli/upgrade.js.map +1 -0
- package/dist/client/AssistantChat.js +1 -1
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/HighlightedCodeBlock.d.ts +2 -0
- package/dist/client/HighlightedCodeBlock.d.ts.map +1 -1
- package/dist/client/HighlightedCodeBlock.js +10 -1
- package/dist/client/HighlightedCodeBlock.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +32 -4
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +61 -8
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +12 -0
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +136 -42
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +2 -9
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/session-replay.d.ts +0 -8
- package/dist/client/session-replay.d.ts.map +1 -1
- package/dist/client/session-replay.js +3 -80
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +52 -19
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/SettingsSection.d.ts +19 -4
- package/dist/client/settings/SettingsSection.d.ts.map +1 -1
- package/dist/client/settings/SettingsSection.js +33 -4
- package/dist/client/settings/SettingsSection.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +9 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +20 -2
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +85 -5
- package/dist/extensions/actions.js.map +1 -1
- package/dist/notifications/channels.d.ts +8 -3
- package/dist/notifications/channels.d.ts.map +1 -1
- package/dist/notifications/channels.js +61 -22
- package/dist/notifications/channels.js.map +1 -1
- package/dist/notifications/registry.d.ts.map +1 -1
- package/dist/notifications/registry.js +14 -3
- package/dist/notifications/registry.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/notifications/types.d.ts +4 -1
- package/dist/notifications/types.d.ts.map +1 -1
- package/dist/notifications/types.js.map +1 -1
- package/dist/observability/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/agent-chat-plugin.d.ts +5 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +2 -2
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/request-context.d.ts +7 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js.map +1 -1
- package/dist/styles/agent-conversation.css +1 -1
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/default/AGENTS.md +10 -3
- package/dist/templates/default/package.json +2 -1
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/headless/AGENTS.md +9 -3
- package/dist/templates/headless/package.json +1 -0
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/workspace-root/AGENTS.md +10 -4
- package/dist/templates/workspace-root/package.json +1 -0
- package/docs/content/faq.mdx +17 -0
- package/docs/content/notifications.mdx +12 -6
- package/package.json +2 -2
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/default/AGENTS.md +10 -3
- package/src/templates/default/package.json +2 -1
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/headless/AGENTS.md +9 -3
- package/src/templates/headless/package.json +1 -0
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/workspace-root/AGENTS.md +10 -4
- package/src/templates/workspace-root/package.json +1 -0
- package/corpus/templates/analytics/changelog/2026-07-08-session-replay-clamps-ultra-wide-viewports-while-keeping-the.md +0 -6
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import { IconChevronDown, IconCheck } from "@tabler/icons-react";
|
|
2
|
-
import type
|
|
2
|
+
import { createContext, useContext, type ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where a settings section is being rendered.
|
|
8
|
+
*
|
|
9
|
+
* - `sidebar`: the compact agent sidebar panel (dense, small type).
|
|
10
|
+
* - `page`: the full-width settings page, styled as a polished card that
|
|
11
|
+
* matches the shadcn `Card` surface used by app-owned settings tabs.
|
|
12
|
+
*/
|
|
13
|
+
export type SettingsSurface = "sidebar" | "page";
|
|
14
|
+
|
|
15
|
+
const SettingsSurfaceContext = createContext<SettingsSurface>("sidebar");
|
|
16
|
+
|
|
17
|
+
export function SettingsSurfaceProvider({
|
|
18
|
+
surface,
|
|
19
|
+
children,
|
|
20
|
+
}: {
|
|
21
|
+
surface: SettingsSurface;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}) {
|
|
24
|
+
return (
|
|
25
|
+
<SettingsSurfaceContext.Provider value={surface}>
|
|
26
|
+
{children}
|
|
27
|
+
</SettingsSurfaceContext.Provider>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function useSettingsSurface(): SettingsSurface {
|
|
32
|
+
return useContext(SettingsSurfaceContext);
|
|
33
|
+
}
|
|
3
34
|
|
|
4
35
|
interface SettingsSectionProps {
|
|
5
36
|
id?: string;
|
|
@@ -15,10 +46,126 @@ interface SettingsSectionProps {
|
|
|
15
46
|
}
|
|
16
47
|
|
|
17
48
|
/**
|
|
18
|
-
* Collapsible settings section
|
|
19
|
-
*
|
|
49
|
+
* Collapsible settings section. Renders as a compact row in the agent sidebar
|
|
50
|
+
* and as a polished, shadcn-style card on the full settings page (so the
|
|
51
|
+
* framework tabs match app-owned General/Team cards). The visual surface is
|
|
52
|
+
* read from `SettingsSurfaceContext`.
|
|
20
53
|
*/
|
|
21
|
-
export function SettingsSection({
|
|
54
|
+
export function SettingsSection(props: SettingsSectionProps) {
|
|
55
|
+
const surface = useSettingsSurface();
|
|
56
|
+
return surface === "page" ? (
|
|
57
|
+
<PageSettingsSection {...props} />
|
|
58
|
+
) : (
|
|
59
|
+
<SidebarSettingsSection {...props} />
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function ConnectedDot({ size }: { size: "sm" | "md" }) {
|
|
64
|
+
const dim = size === "sm" ? "h-4 w-4" : "h-5 w-5";
|
|
65
|
+
const stroke = size === "sm" ? 3 : 2.5;
|
|
66
|
+
const glyph = size === "sm" ? 10 : 12;
|
|
67
|
+
return (
|
|
68
|
+
<span
|
|
69
|
+
className={cn(
|
|
70
|
+
"flex shrink-0 items-center justify-center rounded-full bg-green-500/15 text-green-500",
|
|
71
|
+
dim,
|
|
72
|
+
)}
|
|
73
|
+
>
|
|
74
|
+
<IconCheck size={glyph} stroke={stroke} />
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function StatusBadge({
|
|
80
|
+
label,
|
|
81
|
+
tone,
|
|
82
|
+
size,
|
|
83
|
+
}: {
|
|
84
|
+
label: string;
|
|
85
|
+
tone: "muted" | "required";
|
|
86
|
+
size: "sm" | "md";
|
|
87
|
+
}) {
|
|
88
|
+
return (
|
|
89
|
+
<span
|
|
90
|
+
className={cn(
|
|
91
|
+
"shrink-0 rounded-full font-semibold uppercase tracking-wide",
|
|
92
|
+
size === "sm" ? "px-1.5 py-0.5 text-[9px]" : "px-2 py-0.5 text-[10px]",
|
|
93
|
+
tone === "required"
|
|
94
|
+
? "bg-amber-500/15 text-amber-600 dark:text-amber-400"
|
|
95
|
+
: "bg-muted text-muted-foreground",
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
{label}
|
|
99
|
+
</span>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function PageSettingsSection({
|
|
104
|
+
id,
|
|
105
|
+
icon,
|
|
106
|
+
title,
|
|
107
|
+
subtitle,
|
|
108
|
+
badge,
|
|
109
|
+
required,
|
|
110
|
+
connected,
|
|
111
|
+
open = false,
|
|
112
|
+
onToggle,
|
|
113
|
+
children,
|
|
114
|
+
}: SettingsSectionProps) {
|
|
115
|
+
return (
|
|
116
|
+
<div
|
|
117
|
+
id={id}
|
|
118
|
+
className={cn(
|
|
119
|
+
"scroll-mt-16 overflow-hidden rounded-lg border bg-card text-card-foreground shadow-sm transition-colors",
|
|
120
|
+
open ? "border-border" : "border-border/60",
|
|
121
|
+
)}
|
|
122
|
+
>
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
onClick={onToggle}
|
|
126
|
+
aria-expanded={open}
|
|
127
|
+
className="flex w-full items-start justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/40 sm:px-6 sm:py-5"
|
|
128
|
+
>
|
|
129
|
+
<div className="flex min-w-0 items-start gap-3">
|
|
130
|
+
<span className="mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground [&>svg]:size-[18px]">
|
|
131
|
+
{icon}
|
|
132
|
+
</span>
|
|
133
|
+
<span className="flex min-w-0 flex-col gap-1.5">
|
|
134
|
+
<span className="flex flex-wrap items-center gap-2">
|
|
135
|
+
<span className="text-base font-semibold leading-none tracking-tight text-foreground">
|
|
136
|
+
{title}
|
|
137
|
+
</span>
|
|
138
|
+
{connected && <ConnectedDot size="md" />}
|
|
139
|
+
{required && !connected && (
|
|
140
|
+
<StatusBadge label="Required" tone="required" size="md" />
|
|
141
|
+
)}
|
|
142
|
+
{badge && <StatusBadge label={badge} tone="muted" size="md" />}
|
|
143
|
+
</span>
|
|
144
|
+
{subtitle && (
|
|
145
|
+
<span className="text-sm leading-snug text-muted-foreground">
|
|
146
|
+
{subtitle}
|
|
147
|
+
</span>
|
|
148
|
+
)}
|
|
149
|
+
</span>
|
|
150
|
+
</div>
|
|
151
|
+
<IconChevronDown
|
|
152
|
+
size={18}
|
|
153
|
+
className={cn(
|
|
154
|
+
"mt-1 shrink-0 text-muted-foreground transition-transform",
|
|
155
|
+
open && "rotate-180",
|
|
156
|
+
)}
|
|
157
|
+
/>
|
|
158
|
+
</button>
|
|
159
|
+
{open && (
|
|
160
|
+
<div className="border-t border-border/60 px-5 pb-5 pt-5 sm:px-6 sm:pb-6">
|
|
161
|
+
{children}
|
|
162
|
+
</div>
|
|
163
|
+
)}
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function SidebarSettingsSection({
|
|
22
169
|
id,
|
|
23
170
|
icon,
|
|
24
171
|
title,
|
|
@@ -42,21 +189,11 @@ export function SettingsSection({
|
|
|
42
189
|
<span className="text-[12px] font-medium text-foreground truncate">
|
|
43
190
|
{title}
|
|
44
191
|
</span>
|
|
45
|
-
{connected &&
|
|
46
|
-
<span className="flex items-center justify-center shrink-0 rounded-full bg-green-500/15 text-green-500 w-4 h-4">
|
|
47
|
-
<IconCheck size={10} stroke={3} />
|
|
48
|
-
</span>
|
|
49
|
-
)}
|
|
192
|
+
{connected && <ConnectedDot size="sm" />}
|
|
50
193
|
{required && !connected && (
|
|
51
|
-
<
|
|
52
|
-
Required
|
|
53
|
-
</span>
|
|
54
|
-
)}
|
|
55
|
-
{badge && (
|
|
56
|
-
<span className="shrink-0 rounded-full bg-accent/60 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground">
|
|
57
|
-
{badge}
|
|
58
|
-
</span>
|
|
194
|
+
<StatusBadge label="Required" tone="muted" size="sm" />
|
|
59
195
|
)}
|
|
196
|
+
{badge && <StatusBadge label={badge} tone="muted" size="sm" />}
|
|
60
197
|
</div>
|
|
61
198
|
<IconChevronDown
|
|
62
199
|
size={12}
|
|
@@ -15,6 +15,16 @@ import {
|
|
|
15
15
|
|
|
16
16
|
export type ContentPart =
|
|
17
17
|
| { type: "text"; text: string }
|
|
18
|
+
| {
|
|
19
|
+
/**
|
|
20
|
+
* Model chain-of-thought / extended-thinking prose. Streamed from
|
|
21
|
+
* server `thinking` SSE events (and code-agent thinking transcript
|
|
22
|
+
* items). Rendered as a collapsible plain-English cell — not a tool
|
|
23
|
+
* call.
|
|
24
|
+
*/
|
|
25
|
+
type: "reasoning";
|
|
26
|
+
text: string;
|
|
27
|
+
}
|
|
18
28
|
| {
|
|
19
29
|
type: "tool-call";
|
|
20
30
|
toolCallId: string;
|
|
@@ -669,7 +679,7 @@ function pendingToolNames(content: ContentPart[]): {
|
|
|
669
679
|
|
|
670
680
|
function contentSnapshot(content: ContentPart[]): ContentPart[] {
|
|
671
681
|
return content.map((part) => {
|
|
672
|
-
if (part.type === "text") return { ...part };
|
|
682
|
+
if (part.type === "text" || part.type === "reasoning") return { ...part };
|
|
673
683
|
return {
|
|
674
684
|
...part,
|
|
675
685
|
args: { ...part.args },
|
|
@@ -952,6 +962,23 @@ export function processEvent(
|
|
|
952
962
|
};
|
|
953
963
|
}
|
|
954
964
|
|
|
965
|
+
if (ev.type === "thinking") {
|
|
966
|
+
// Model chain-of-thought. Coalesce consecutive deltas into one reasoning
|
|
967
|
+
// part so the UI can render a single collapsible "Thinking" cell.
|
|
968
|
+
const delta = ev.text ?? "";
|
|
969
|
+
if (!delta) return { action: "continue" };
|
|
970
|
+
const lastPart = content[content.length - 1];
|
|
971
|
+
if (lastPart && lastPart.type === "reasoning") {
|
|
972
|
+
lastPart.text += delta;
|
|
973
|
+
} else {
|
|
974
|
+
content.push({ type: "reasoning", text: delta });
|
|
975
|
+
}
|
|
976
|
+
return {
|
|
977
|
+
action: "yield",
|
|
978
|
+
result: { content: contentSnapshot(content) } as ChatModelRunResult,
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
|
|
955
982
|
if (ev.type === "stream_keepalive") {
|
|
956
983
|
return { action: "continue" };
|
|
957
984
|
}
|
|
@@ -1400,7 +1427,7 @@ function clearAssistantDraftContent(content: ContentPart[]): void {
|
|
|
1400
1427
|
for (let index = content.length - 1; index >= 0; index--) {
|
|
1401
1428
|
const part = content[index];
|
|
1402
1429
|
if (!part) continue;
|
|
1403
|
-
if (part.type === "text") {
|
|
1430
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
1404
1431
|
content.splice(index, 1);
|
|
1405
1432
|
continue;
|
|
1406
1433
|
}
|
|
@@ -3,6 +3,7 @@ import type { ActionRunContext } from "../action.js";
|
|
|
3
3
|
import type { ActionEntry } from "../agent/production-agent.js";
|
|
4
4
|
import type { AgentChatAttachment } from "../agent/types.js";
|
|
5
5
|
import { writeAppState } from "../application-state/script-helpers.js";
|
|
6
|
+
import { getRequestRunContext } from "../server/request-context.js";
|
|
6
7
|
import { resolveAccess } from "../sharing/access.js";
|
|
7
8
|
import type {
|
|
8
9
|
ExtensionContentEdit,
|
|
@@ -38,6 +39,8 @@ import {
|
|
|
38
39
|
unhideExtension,
|
|
39
40
|
updateExtension,
|
|
40
41
|
updateExtensionContent,
|
|
42
|
+
type ExtensionHistoryDetail,
|
|
43
|
+
type ExtensionHistoryEntry,
|
|
41
44
|
type ExtensionRow,
|
|
42
45
|
} from "./store.js";
|
|
43
46
|
|
|
@@ -126,7 +129,7 @@ export function createExtensionActionEntries(): Record<string, ActionEntry> {
|
|
|
126
129
|
"get-extension": {
|
|
127
130
|
tool: {
|
|
128
131
|
description:
|
|
129
|
-
"Get one existing extension by id. Use this when <current-screen> or <current-url> contains extensionId for the current extension; do not call list-extensions just to rediscover that id. Defaults to including the full Alpine.js content so you can make a targeted update-extension edit.",
|
|
132
|
+
"Get one existing extension by id. Use this when <current-screen> or <current-url> contains extensionId for the current extension; do not call list-extensions just to rediscover that id. Defaults to including the full Alpine.js content once per run so you can make a targeted update-extension edit; repeated unchanged reads return compact metadata unless forceContent=true.",
|
|
130
133
|
parameters: {
|
|
131
134
|
type: "object",
|
|
132
135
|
properties: {
|
|
@@ -140,6 +143,11 @@ export function createExtensionActionEntries(): Record<string, ActionEntry> {
|
|
|
140
143
|
description:
|
|
141
144
|
"Include full Alpine.js content. Defaults to true for targeted edits.",
|
|
142
145
|
},
|
|
146
|
+
forceContent: {
|
|
147
|
+
type: "boolean",
|
|
148
|
+
description:
|
|
149
|
+
"Return full content even if this run already read the same unchanged body. Use sparingly; prefer update-extension edits after the first read.",
|
|
150
|
+
},
|
|
143
151
|
},
|
|
144
152
|
required: ["id"],
|
|
145
153
|
},
|
|
@@ -151,14 +159,16 @@ export function createExtensionActionEntries(): Record<string, ActionEntry> {
|
|
|
151
159
|
args?.includeContent === undefined
|
|
152
160
|
? true
|
|
153
161
|
: coerceBoolean(args.includeContent);
|
|
162
|
+
const forceContent = coerceBoolean(args?.forceContent);
|
|
154
163
|
const localExtension = await getLocalExtension(id);
|
|
155
164
|
if (localExtension) {
|
|
156
165
|
return {
|
|
157
166
|
ok: true,
|
|
158
|
-
extension: await
|
|
167
|
+
extension: await summarizeExtensionForAgentRead(
|
|
159
168
|
localExtension,
|
|
160
169
|
new Set(),
|
|
161
170
|
includeContent,
|
|
171
|
+
forceContent,
|
|
162
172
|
),
|
|
163
173
|
};
|
|
164
174
|
}
|
|
@@ -167,10 +177,11 @@ export function createExtensionActionEntries(): Record<string, ActionEntry> {
|
|
|
167
177
|
const hiddenIds = await getHiddenExtensionIdsForCurrentUser();
|
|
168
178
|
return {
|
|
169
179
|
ok: true,
|
|
170
|
-
extension: await
|
|
180
|
+
extension: await summarizeExtensionForAgentRead(
|
|
171
181
|
extension,
|
|
172
182
|
hiddenIds,
|
|
173
183
|
includeContent,
|
|
184
|
+
forceContent,
|
|
174
185
|
),
|
|
175
186
|
};
|
|
176
187
|
},
|
|
@@ -223,7 +234,7 @@ export function createExtensionActionEntries(): Record<string, ActionEntry> {
|
|
|
223
234
|
"get-extension-history-version": {
|
|
224
235
|
tool: {
|
|
225
236
|
description:
|
|
226
|
-
"Get one extension history version with its previous-version diff. Use after list-extension-history when the user wants to inspect exactly what changed.",
|
|
237
|
+
"Get one extension history version with its previous-version diff. Use after list-extension-history when the user wants to inspect exactly what changed. Full HTML bodies are omitted by default; set includeContent=true only when restoring or manually comparing full source.",
|
|
227
238
|
parameters: {
|
|
228
239
|
type: "object",
|
|
229
240
|
properties: {
|
|
@@ -235,6 +246,11 @@ export function createExtensionActionEntries(): Record<string, ActionEntry> {
|
|
|
235
246
|
type: "number",
|
|
236
247
|
description: "History version number to inspect.",
|
|
237
248
|
},
|
|
249
|
+
includeContent: {
|
|
250
|
+
type: "boolean",
|
|
251
|
+
description:
|
|
252
|
+
"Include full HTML for the current and previous versions. Defaults to false to keep agent context compact.",
|
|
253
|
+
},
|
|
238
254
|
},
|
|
239
255
|
required: ["id", "version"],
|
|
240
256
|
},
|
|
@@ -252,7 +268,13 @@ export function createExtensionActionEntries(): Record<string, ActionEntry> {
|
|
|
252
268
|
if (!detail) {
|
|
253
269
|
return `Error: extension history version not found: ${id}#${version}`;
|
|
254
270
|
}
|
|
255
|
-
return {
|
|
271
|
+
return {
|
|
272
|
+
ok: true,
|
|
273
|
+
...compactExtensionHistoryDetail(
|
|
274
|
+
detail,
|
|
275
|
+
coerceBoolean(args?.includeContent),
|
|
276
|
+
),
|
|
277
|
+
};
|
|
256
278
|
},
|
|
257
279
|
readOnly: true,
|
|
258
280
|
},
|
|
@@ -1059,11 +1081,97 @@ async function summarizeExtension(
|
|
|
1059
1081
|
hiddenBy: row.hiddenBy,
|
|
1060
1082
|
createdAt: row.createdAt,
|
|
1061
1083
|
updatedAt: row.updatedAt,
|
|
1084
|
+
contentLength: row.content.length,
|
|
1085
|
+
contentHash: contentFingerprint(row.content),
|
|
1062
1086
|
...(local ? { source: row.source } : {}),
|
|
1063
1087
|
...(includeContent ? { content: row.content } : {}),
|
|
1064
1088
|
};
|
|
1065
1089
|
}
|
|
1066
1090
|
|
|
1091
|
+
async function summarizeExtensionForAgentRead(
|
|
1092
|
+
row: ExtensionRow | LocalExtensionRow,
|
|
1093
|
+
hiddenIds: Set<string>,
|
|
1094
|
+
includeContent: boolean,
|
|
1095
|
+
forceContent: boolean,
|
|
1096
|
+
) {
|
|
1097
|
+
if (!includeContent) {
|
|
1098
|
+
return summarizeExtension(row, hiddenIds, false);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
const fingerprint = contentFingerprint(row.content);
|
|
1102
|
+
const runCtx = getRequestRunContext();
|
|
1103
|
+
const reads = runCtx ? (runCtx.extensionContentReads ??= {}) : undefined;
|
|
1104
|
+
const alreadySent = !forceContent && reads?.[row.id] === fingerprint;
|
|
1105
|
+
if (!alreadySent && reads) {
|
|
1106
|
+
reads[row.id] = fingerprint;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
const summary = await summarizeExtension(row, hiddenIds, !alreadySent);
|
|
1110
|
+
if (!alreadySent) return summary;
|
|
1111
|
+
|
|
1112
|
+
return {
|
|
1113
|
+
...summary,
|
|
1114
|
+
contentOmitted: {
|
|
1115
|
+
reason: "unchanged-content-already-returned-this-run",
|
|
1116
|
+
contentHash: fingerprint,
|
|
1117
|
+
contentLength: row.content.length,
|
|
1118
|
+
next: "Use the content already returned earlier in this run and call update-extension with focused edits/patches. Set forceContent=true only if you truly need the full body again.",
|
|
1119
|
+
},
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
function compactExtensionHistoryDetail(
|
|
1124
|
+
detail: ExtensionHistoryDetail,
|
|
1125
|
+
includeContent: boolean,
|
|
1126
|
+
): ExtensionHistoryDetail & {
|
|
1127
|
+
diffOmitted?: { omittedLines: number; maxLines: number };
|
|
1128
|
+
} {
|
|
1129
|
+
const diffMaxLines = 400;
|
|
1130
|
+
const fullDiff = detail.diff ?? [];
|
|
1131
|
+
const diff =
|
|
1132
|
+
fullDiff.length > diffMaxLines
|
|
1133
|
+
? [...fullDiff.slice(0, 200), ...fullDiff.slice(fullDiff.length - 200)]
|
|
1134
|
+
: fullDiff;
|
|
1135
|
+
return {
|
|
1136
|
+
...detail,
|
|
1137
|
+
entry: compactHistoryEntry(detail.entry, includeContent),
|
|
1138
|
+
previous: detail.previous
|
|
1139
|
+
? compactHistoryEntry(detail.previous, includeContent)
|
|
1140
|
+
: null,
|
|
1141
|
+
diff,
|
|
1142
|
+
...(fullDiff.length > diff.length
|
|
1143
|
+
? {
|
|
1144
|
+
diffOmitted: {
|
|
1145
|
+
omittedLines: fullDiff.length - diff.length,
|
|
1146
|
+
maxLines: diffMaxLines,
|
|
1147
|
+
},
|
|
1148
|
+
}
|
|
1149
|
+
: {}),
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function compactHistoryEntry(
|
|
1154
|
+
entry: ExtensionHistoryEntry,
|
|
1155
|
+
includeContent: boolean,
|
|
1156
|
+
): ExtensionHistoryEntry & { contentHash?: string } {
|
|
1157
|
+
const content = entry.content ?? "";
|
|
1158
|
+
const withHash = {
|
|
1159
|
+
...entry,
|
|
1160
|
+
...(content ? { contentHash: contentFingerprint(content) } : {}),
|
|
1161
|
+
};
|
|
1162
|
+
if (includeContent) return withHash;
|
|
1163
|
+
const { content: _content, ...withoutContent } = withHash;
|
|
1164
|
+
return withoutContent;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
function contentFingerprint(content: string): string {
|
|
1168
|
+
let hash = 5381;
|
|
1169
|
+
for (let i = 0; i < content.length; i++) {
|
|
1170
|
+
hash = (hash * 33) ^ content.charCodeAt(i);
|
|
1171
|
+
}
|
|
1172
|
+
return `${content.length.toString(36)}-${(hash >>> 0).toString(36)}`;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1067
1175
|
async function localExtensionEditMessage(id: string): Promise<string | null> {
|
|
1068
1176
|
const localExtension = await getLocalExtension(id);
|
|
1069
1177
|
if (!localExtension) return null;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Built-in notification channels.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Webhook and Slack are always registered. Delivery uses (in order):
|
|
5
|
+
* 1. per-notification `metadata.webhookUrl` / `metadata.slackWebhookUrl`
|
|
6
|
+
* 2. the matching `NOTIFICATIONS_*` env URL (workspace default)
|
|
7
|
+
* If neither is set, that channel no-ops for the emission.
|
|
8
|
+
*
|
|
5
9
|
* Extra channels can be registered at any time via
|
|
6
10
|
* `registerNotificationChannel()` from a server plugin.
|
|
7
11
|
*
|
|
8
|
-
* NOTIFICATIONS_WEBHOOK_URL → POST
|
|
12
|
+
* NOTIFICATIONS_WEBHOOK_URL → default POST JSON URL when metadata omits one.
|
|
9
13
|
* Supports `${keys.NAME}` substitution — the raw
|
|
10
14
|
* value never enters the agent context.
|
|
11
15
|
* NOTIFICATIONS_WEBHOOK_AUTH → optional `Authorization` header value (also
|
|
12
16
|
* supports `${keys.NAME}`).
|
|
13
17
|
* NOTIFICATIONS_SLACK_WEBHOOK_URL
|
|
14
|
-
* →
|
|
18
|
+
* → default Slack incoming webhook when metadata
|
|
19
|
+
* omits `slackWebhookUrl`.
|
|
15
20
|
* Supports `${keys.NAME}` substitution.
|
|
16
21
|
* NOTIFICATIONS_EMAIL_CHANNEL=1
|
|
17
22
|
* → enable the built-in email channel for
|
|
@@ -30,7 +35,7 @@ import {
|
|
|
30
35
|
} from "../secrets/substitution.js";
|
|
31
36
|
import { sendEmail } from "../server/email.js";
|
|
32
37
|
import { registerNotificationChannel } from "./registry.js";
|
|
33
|
-
import type { NotificationChannel } from "./types.js";
|
|
38
|
+
import type { NotificationChannel, NotificationInput } from "./types.js";
|
|
34
39
|
|
|
35
40
|
let _registered = false;
|
|
36
41
|
|
|
@@ -38,30 +43,38 @@ export function registerBuiltinNotificationChannels(): void {
|
|
|
38
43
|
if (_registered) return;
|
|
39
44
|
_registered = true;
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const emailRecipients = process.env.NOTIFICATIONS_EMAIL_RECIPIENTS?.trim();
|
|
52
|
-
if (process.env.NOTIFICATIONS_EMAIL_CHANNEL === "1" || emailRecipients) {
|
|
53
|
-
registerNotificationChannel(createEmailChannel());
|
|
54
|
-
}
|
|
46
|
+
registerNotificationChannel(
|
|
47
|
+
createWebhookChannel(process.env.NOTIFICATIONS_WEBHOOK_URL),
|
|
48
|
+
);
|
|
49
|
+
registerNotificationChannel(
|
|
50
|
+
createSlackWebhookChannel(process.env.NOTIFICATIONS_SLACK_WEBHOOK_URL),
|
|
51
|
+
);
|
|
52
|
+
// Email is always registered so per-notification `metadata.emailRecipients`
|
|
53
|
+
// work without a workspace-wide env flag (same pattern as webhook/slack).
|
|
54
|
+
registerNotificationChannel(createEmailChannel());
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function createWebhookChannel(
|
|
57
|
+
function createWebhookChannel(
|
|
58
|
+
envUrlTemplate: string | undefined,
|
|
59
|
+
): NotificationChannel {
|
|
58
60
|
const authTemplate = process.env.NOTIFICATIONS_WEBHOOK_AUTH;
|
|
59
61
|
return {
|
|
60
62
|
name: "webhook",
|
|
61
63
|
async deliver(input, meta) {
|
|
64
|
+
const overrideUrlTemplate = deliveryMetadataString(
|
|
65
|
+
input.metadata,
|
|
66
|
+
"webhookUrl",
|
|
67
|
+
);
|
|
68
|
+
const urlTemplate =
|
|
69
|
+
overrideUrlTemplate ??
|
|
70
|
+
metadataString(input.metadata, "webhookUrl") ??
|
|
71
|
+
envUrlTemplate?.trim();
|
|
72
|
+
// No-op when neither a per-notification nor workspace URL is set —
|
|
73
|
+
// mirrors email's empty-recipients behavior so notify-all stays quiet.
|
|
74
|
+
if (!urlTemplate) return false;
|
|
62
75
|
const { url, headers } = await resolveWebhookRequest(
|
|
63
76
|
urlTemplate,
|
|
64
|
-
authTemplate,
|
|
77
|
+
overrideUrlTemplate ? undefined : authTemplate,
|
|
65
78
|
meta.owner,
|
|
66
79
|
"webhook",
|
|
67
80
|
);
|
|
@@ -74,7 +87,7 @@ function createWebhookChannel(urlTemplate: string): NotificationChannel {
|
|
|
74
87
|
severity: input.severity,
|
|
75
88
|
title: input.title,
|
|
76
89
|
body: input.body,
|
|
77
|
-
metadata: input.metadata,
|
|
90
|
+
metadata: scrubDeliveryMetadata(input.metadata),
|
|
78
91
|
owner: meta.owner,
|
|
79
92
|
emittedAt: new Date().toISOString(),
|
|
80
93
|
}),
|
|
@@ -92,14 +105,25 @@ function createWebhookChannel(urlTemplate: string): NotificationChannel {
|
|
|
92
105
|
};
|
|
93
106
|
}
|
|
94
107
|
|
|
95
|
-
function createSlackWebhookChannel(
|
|
108
|
+
function createSlackWebhookChannel(
|
|
109
|
+
envUrlTemplate: string | undefined,
|
|
110
|
+
): NotificationChannel {
|
|
96
111
|
const authTemplate = process.env.NOTIFICATIONS_SLACK_WEBHOOK_AUTH;
|
|
97
112
|
return {
|
|
98
113
|
name: "slack",
|
|
99
114
|
async deliver(input, meta) {
|
|
115
|
+
const overrideUrlTemplate = deliveryMetadataString(
|
|
116
|
+
input.metadata,
|
|
117
|
+
"slackWebhookUrl",
|
|
118
|
+
);
|
|
119
|
+
const urlTemplate =
|
|
120
|
+
overrideUrlTemplate ??
|
|
121
|
+
metadataString(input.metadata, "slackWebhookUrl") ??
|
|
122
|
+
envUrlTemplate?.trim();
|
|
123
|
+
if (!urlTemplate) return false;
|
|
100
124
|
const { url, headers } = await resolveWebhookRequest(
|
|
101
125
|
urlTemplate,
|
|
102
|
-
authTemplate,
|
|
126
|
+
overrideUrlTemplate ? undefined : authTemplate,
|
|
103
127
|
meta.owner,
|
|
104
128
|
"Slack webhook",
|
|
105
129
|
);
|
|
@@ -159,7 +183,7 @@ function createEmailChannel(): NotificationChannel {
|
|
|
159
183
|
name: "email",
|
|
160
184
|
async deliver(input) {
|
|
161
185
|
const recipients = notificationEmailRecipients(input.metadata);
|
|
162
|
-
if (recipients.length === 0) return;
|
|
186
|
+
if (recipients.length === 0) return false;
|
|
163
187
|
const subject =
|
|
164
188
|
typeof input.metadata?.emailSubject === "string" &&
|
|
165
189
|
input.metadata.emailSubject.trim()
|
|
@@ -240,6 +264,41 @@ async function resolveWebhookRequest(
|
|
|
240
264
|
return { url, headers };
|
|
241
265
|
}
|
|
242
266
|
|
|
267
|
+
function metadataString(
|
|
268
|
+
metadata: NotificationInput["metadata"],
|
|
269
|
+
key: string,
|
|
270
|
+
): string | undefined {
|
|
271
|
+
const value = metadata?.[key];
|
|
272
|
+
if (typeof value !== "string") return undefined;
|
|
273
|
+
const trimmed = value.trim();
|
|
274
|
+
return trimmed || undefined;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function deliveryMetadataString(
|
|
278
|
+
metadata: NotificationInput["metadata"],
|
|
279
|
+
key: string,
|
|
280
|
+
): string | undefined {
|
|
281
|
+
const delivery = metadata?.delivery;
|
|
282
|
+
if (!delivery || typeof delivery !== "object" || Array.isArray(delivery)) {
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
const value = (delivery as Record<string, unknown>)[key];
|
|
286
|
+
if (typeof value !== "string") return undefined;
|
|
287
|
+
const trimmed = value.trim();
|
|
288
|
+
return trimmed || undefined;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function scrubDeliveryMetadata(
|
|
292
|
+
metadata: Record<string, unknown> | undefined,
|
|
293
|
+
): Record<string, unknown> | undefined {
|
|
294
|
+
if (!metadata) return undefined;
|
|
295
|
+
const entries = Object.entries(metadata).filter(
|
|
296
|
+
([key]) =>
|
|
297
|
+
key !== "delivery" && key !== "webhookUrl" && key !== "slackWebhookUrl",
|
|
298
|
+
);
|
|
299
|
+
return entries.length ? Object.fromEntries(entries) : undefined;
|
|
300
|
+
}
|
|
301
|
+
|
|
243
302
|
function notificationEmailRecipients(
|
|
244
303
|
metadata: Record<string, unknown> | undefined,
|
|
245
304
|
): string[] {
|
|
@@ -275,7 +334,11 @@ function scrubEmailMetadata(
|
|
|
275
334
|
): Record<string, unknown> | null {
|
|
276
335
|
if (!metadata) return null;
|
|
277
336
|
const entries = Object.entries(metadata).filter(
|
|
278
|
-
([key]) =>
|
|
337
|
+
([key]) =>
|
|
338
|
+
key !== "emailRecipients" &&
|
|
339
|
+
key !== "emailSubject" &&
|
|
340
|
+
key !== "webhookUrl" &&
|
|
341
|
+
key !== "slackWebhookUrl",
|
|
279
342
|
);
|
|
280
343
|
return entries.length ? Object.fromEntries(entries) : null;
|
|
281
344
|
}
|
|
@@ -105,6 +105,7 @@ export async function notifyWithDelivery(
|
|
|
105
105
|
body: truncate(input.body, MAX_BODY_LEN),
|
|
106
106
|
};
|
|
107
107
|
const channels = selectChannels(input.channels);
|
|
108
|
+
const storedMetadata = scrubStoredMetadata(input.metadata);
|
|
108
109
|
|
|
109
110
|
// The inbox channel is always included unless explicitly excluded.
|
|
110
111
|
const runInbox = !input.channels || input.channels.includes("inbox");
|
|
@@ -120,7 +121,7 @@ export async function notifyWithDelivery(
|
|
|
120
121
|
severity: input.severity,
|
|
121
122
|
title: input.title,
|
|
122
123
|
body: input.body,
|
|
123
|
-
metadata:
|
|
124
|
+
metadata: storedMetadata,
|
|
124
125
|
deliveredChannels: ["inbox"],
|
|
125
126
|
});
|
|
126
127
|
delivered.push("inbox");
|
|
@@ -132,13 +133,15 @@ export async function notifyWithDelivery(
|
|
|
132
133
|
// Await every channel so a 500-ing webhook doesn't end up in `delivered`.
|
|
133
134
|
const results = await Promise.allSettled(
|
|
134
135
|
channels.map(async (channel) => {
|
|
135
|
-
await channel.deliver(input, meta);
|
|
136
|
+
const delivered = await channel.deliver(input, meta);
|
|
137
|
+
// Explicit `false` means the channel skipped (no URL / recipients).
|
|
138
|
+
if (delivered === false) return null;
|
|
136
139
|
return channel.name;
|
|
137
140
|
}),
|
|
138
141
|
);
|
|
139
142
|
results.forEach((r, i) => {
|
|
140
143
|
if (r.status === "fulfilled") {
|
|
141
|
-
delivered.push(r.value);
|
|
144
|
+
if (r.value) delivered.push(r.value);
|
|
142
145
|
} else {
|
|
143
146
|
console.error(
|
|
144
147
|
`[notifications] channel "${channels[i].name}" failed:`,
|
|
@@ -181,6 +184,17 @@ export async function notifyWithDelivery(
|
|
|
181
184
|
return { notification: stored, deliveredChannels: delivered };
|
|
182
185
|
}
|
|
183
186
|
|
|
187
|
+
function scrubStoredMetadata(
|
|
188
|
+
metadata: Record<string, unknown> | undefined,
|
|
189
|
+
): Record<string, unknown> | undefined {
|
|
190
|
+
if (!metadata) return undefined;
|
|
191
|
+
const entries = Object.entries(metadata).filter(
|
|
192
|
+
([key]) =>
|
|
193
|
+
key !== "delivery" && key !== "webhookUrl" && key !== "slackWebhookUrl",
|
|
194
|
+
);
|
|
195
|
+
return entries.length ? Object.fromEntries(entries) : undefined;
|
|
196
|
+
}
|
|
197
|
+
|
|
184
198
|
function selectChannels(allowlist?: string[]): NotificationChannel[] {
|
|
185
199
|
const registry = getRegistry();
|
|
186
200
|
const all = Array.from(registry.values());
|