@agent-native/core 0.68.1 → 0.68.2
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/README.md +4 -4
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +10 -0
- package/corpus/core/docs/content/authentication.md +16 -2
- package/corpus/core/docs/content/template-analytics.md +14 -9
- package/corpus/core/docs/content/template-clips.md +30 -2
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/pr-visual-recap-workflow.ts +1 -1
- package/corpus/core/src/client/CommandMenu.tsx +98 -3
- package/corpus/core/src/client/ConnectBuilderCard.tsx +11 -2
- package/corpus/core/src/client/index.ts +2 -0
- package/corpus/core/src/oauth-tokens/google-refresh.ts +32 -17
- package/corpus/core/src/provider-api/index.ts +37 -17
- package/corpus/core/src/server/auth.ts +6 -8
- package/corpus/core/src/server/better-auth-instance.ts +19 -4
- package/corpus/core/src/server/core-routes-plugin.ts +157 -5
- package/corpus/core/src/server/google-oauth-credentials.ts +51 -0
- package/corpus/core/src/server/index.ts +8 -0
- package/corpus/core/src/server/onboarding-html.ts +2 -1
- package/corpus/templates/analytics/app/routes/$.tsx +9 -0
- package/corpus/templates/calendar/app/components/calendar/DayView.tsx +33 -1
- package/corpus/templates/calendar/app/components/calendar/EventAttendeesSection.tsx +11 -3
- package/corpus/templates/calendar/app/components/calendar/EventCard.tsx +25 -2
- package/corpus/templates/calendar/app/components/calendar/EventDetailPanel.tsx +12 -0
- package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +7 -2
- package/corpus/templates/calendar/app/components/calendar/GoogleConnectBanner.tsx +37 -78
- package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +33 -1
- package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +46 -3
- package/corpus/templates/calendar/app/hooks/use-google-auth.ts +203 -2
- package/corpus/templates/calendar/app/lib/event-colors.ts +1 -4
- package/corpus/templates/calendar/app/lib/rsvp-status.tsx +6 -0
- package/corpus/templates/calendar/app/pages/CalendarView.tsx +9 -4
- package/corpus/templates/calendar/app/pages/NotFound.tsx +1 -1
- package/corpus/templates/calendar/app/pages/Settings.tsx +25 -1
- package/corpus/templates/calendar/app/routes/_app.$.tsx +9 -0
- package/corpus/templates/calendar/server/handlers/google-auth.ts +152 -12
- package/corpus/templates/calendar/server/lib/google-calendar.ts +63 -14
- package/corpus/templates/calendar/server/plugins/auth.ts +4 -20
- package/corpus/templates/calendar/shared/api.ts +4 -0
- package/corpus/templates/clips/.agents/skills/recording/SKILL.md +17 -0
- package/corpus/templates/clips/actions/sync-calendars.ts +6 -7
- package/corpus/templates/clips/app/components/capture-install-options.tsx +157 -0
- package/corpus/templates/clips/app/components/library/library-layout.tsx +9 -8
- package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +4 -6
- package/corpus/templates/clips/app/lib/capture-install-options.ts +13 -0
- package/corpus/templates/clips/app/root.tsx +54 -2
- package/corpus/templates/clips/app/routes/_app.dictate.tsx +9 -13
- package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +5 -7
- package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +5 -7
- package/corpus/templates/clips/app/routes/download.tsx +49 -0
- package/corpus/templates/clips/app/routes/record.tsx +4 -4
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +5 -6
- package/corpus/templates/clips/chrome-extension/STORE_DRAFT.md +26 -0
- package/corpus/templates/clips/server/lib/calendar-event-meetings.ts +6 -7
- package/corpus/templates/clips/server/lib/google-calendar-client.ts +61 -0
- package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.get.ts +19 -12
- package/corpus/templates/clips/server/routes/_agent-native/google/callback.get.ts +6 -6
- package/corpus/templates/design/app/pages/NotFound.tsx +1 -1
- package/corpus/templates/design/app/routes/$.tsx +9 -0
- package/corpus/templates/mail/app/pages/NotFound.tsx +1 -1
- package/corpus/templates/mail/app/routes/$.tsx +9 -0
- package/corpus/templates/plan/app/global.css +2 -2
- package/corpus/templates/slides/app/pages/NotFound.tsx +1 -1
- package/corpus/templates/slides/app/routes/$.tsx +9 -0
- package/corpus/templates/slides/server/lib/google-docs-oauth.ts +81 -25
- package/corpus/templates/videos/app/pages/NotFound.tsx +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.js +1 -1
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/client/CommandMenu.d.ts +15 -2
- package/dist/client/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +46 -3
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/ConnectBuilderCard.d.ts.map +1 -1
- package/dist/client/ConnectBuilderCard.js +11 -2
- package/dist/client/ConnectBuilderCard.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/oauth-tokens/google-refresh.d.ts.map +1 -1
- package/dist/oauth-tokens/google-refresh.js +29 -17
- package/dist/oauth-tokens/google-refresh.js.map +1 -1
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +28 -16
- package/dist/provider-api/index.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +6 -6
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +18 -4
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +5 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +107 -5
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/google-oauth-credentials.d.ts +15 -0
- package/dist/server/google-oauth-credentials.d.ts.map +1 -0
- package/dist/server/google-oauth-credentials.js +34 -0
- package/dist/server/google-oauth-credentials.js.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +2 -1
- package/dist/server/onboarding-html.js.map +1 -1
- package/docs/content/authentication.md +16 -2
- package/docs/content/template-analytics.md +14 -9
- package/docs/content/template-clips.md +30 -2
- package/package.json +1 -1
|
@@ -60,6 +60,11 @@ import { DEFAULT_SSR_CACHE_HEADERS, EMPTY_SPECULATION_RULES, } from "../shared/c
|
|
|
60
60
|
export const FRAMEWORK_ROUTE_PREFIX = "/_agent-native";
|
|
61
61
|
export const FRAMEWORK_EVENTS_ROUTE = `${FRAMEWORK_ROUTE_PREFIX}/events`;
|
|
62
62
|
export const LEGACY_FRAMEWORK_EVENTS_ROUTE = `${FRAMEWORK_ROUTE_PREFIX}/poll-events`;
|
|
63
|
+
const DEFAULT_BUILDER_WAITLIST_FORM_ID = "DYTHuM0jlV";
|
|
64
|
+
const DEFAULT_BUILDER_WAITLIST_FORMS_ORIGIN = "https://forms.agent-native.com";
|
|
65
|
+
const BUILDER_WAITLIST_FORM_SOURCE = "connect_builder_card";
|
|
66
|
+
const BUILDER_WAITLIST_FORM_TIMEOUT_MS = 8000;
|
|
67
|
+
const BUILDER_WAITLIST_TEXT_LIMIT = 4000;
|
|
63
68
|
export function resolveFrameworkSseRoutes(sseRoute) {
|
|
64
69
|
return Array.from(new Set([
|
|
65
70
|
sseRoute ?? FRAMEWORK_EVENTS_ROUTE,
|
|
@@ -68,6 +73,85 @@ export function resolveFrameworkSseRoutes(sseRoute) {
|
|
|
68
73
|
]));
|
|
69
74
|
}
|
|
70
75
|
registerBuiltinEngines();
|
|
76
|
+
function cleanBuilderWaitlistText(value, maxLength = BUILDER_WAITLIST_TEXT_LIMIT) {
|
|
77
|
+
if (typeof value !== "string")
|
|
78
|
+
return undefined;
|
|
79
|
+
const trimmed = value.trim();
|
|
80
|
+
if (!trimmed)
|
|
81
|
+
return undefined;
|
|
82
|
+
return trimmed.slice(0, maxLength);
|
|
83
|
+
}
|
|
84
|
+
function normalizeHttpOrigin(value) {
|
|
85
|
+
try {
|
|
86
|
+
const url = new URL(value);
|
|
87
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
88
|
+
return null;
|
|
89
|
+
return url.origin;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function isAgentNativeHostedRequest(event) {
|
|
96
|
+
const hostname = getRequestURL(event).hostname.toLowerCase();
|
|
97
|
+
return (hostname === "agent-native.com" || hostname.endsWith(".agent-native.com"));
|
|
98
|
+
}
|
|
99
|
+
export function resolveBuilderWaitlistFormTargetForRequest(event) {
|
|
100
|
+
if (process.env.AGENT_NATIVE_DISABLE_BUILDER_WAITLIST_FORM === "1") {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const envFormId = process.env.AGENT_NATIVE_BUILDER_WAITLIST_FORM_ID?.trim();
|
|
104
|
+
const envFormsOrigin = process.env.AGENT_NATIVE_BUILDER_WAITLIST_FORMS_ORIGIN?.trim();
|
|
105
|
+
const hasExplicitTarget = Boolean(envFormId || envFormsOrigin);
|
|
106
|
+
if (!hasExplicitTarget && !isAgentNativeHostedRequest(event)) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const formId = envFormId || DEFAULT_BUILDER_WAITLIST_FORM_ID;
|
|
110
|
+
const formsOrigin = normalizeHttpOrigin(envFormsOrigin || DEFAULT_BUILDER_WAITLIST_FORMS_ORIGIN);
|
|
111
|
+
if (!formsOrigin) {
|
|
112
|
+
throw new Error("Invalid Builder waitlist Forms origin");
|
|
113
|
+
}
|
|
114
|
+
return { formId, formsOrigin };
|
|
115
|
+
}
|
|
116
|
+
async function submitBuilderWaitlistForm(event, sessionEmail, body) {
|
|
117
|
+
const target = resolveBuilderWaitlistFormTargetForRequest(event);
|
|
118
|
+
if (!target)
|
|
119
|
+
return { submitted: false };
|
|
120
|
+
const appUrl = cleanBuilderWaitlistText(body.pageUrl ?? body.appUrl, 2000) ??
|
|
121
|
+
cleanBuilderWaitlistText(getHeader(event, "referer"), 2000) ??
|
|
122
|
+
getOrigin(event);
|
|
123
|
+
const source = cleanBuilderWaitlistText(body.source, 100) ?? BUILDER_WAITLIST_FORM_SOURCE;
|
|
124
|
+
const controller = new AbortController();
|
|
125
|
+
const timeout = setTimeout(() => controller.abort(), BUILDER_WAITLIST_FORM_TIMEOUT_MS);
|
|
126
|
+
try {
|
|
127
|
+
const res = await fetch(`${target.formsOrigin}/api/submit/${encodeURIComponent(target.formId)}`, {
|
|
128
|
+
method: "POST",
|
|
129
|
+
headers: { "Content-Type": "application/json" },
|
|
130
|
+
body: JSON.stringify({
|
|
131
|
+
data: {
|
|
132
|
+
email: sessionEmail,
|
|
133
|
+
orgName: cleanBuilderWaitlistText(body.orgName, 500),
|
|
134
|
+
appUrl,
|
|
135
|
+
prompt: cleanBuilderWaitlistText(body.prompt),
|
|
136
|
+
source,
|
|
137
|
+
},
|
|
138
|
+
_hp: "",
|
|
139
|
+
_meta: {
|
|
140
|
+
submitterEmail: sessionEmail,
|
|
141
|
+
pageUrl: appUrl,
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
signal: controller.signal,
|
|
145
|
+
});
|
|
146
|
+
if (!res.ok) {
|
|
147
|
+
throw new Error(`Forms waitlist submission failed (${res.status})`);
|
|
148
|
+
}
|
|
149
|
+
return { submitted: true, formId: target.formId };
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
clearTimeout(timeout);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
71
155
|
function parseBuilderCallbackBoolean(value) {
|
|
72
156
|
if (value == null || value === "")
|
|
73
157
|
return null;
|
|
@@ -984,10 +1068,10 @@ export function createCoreRoutesPlugin(options = {}) {
|
|
|
984
1068
|
});
|
|
985
1069
|
}));
|
|
986
1070
|
// Branch-creation waitlist signup. Used by ConnectBuilderCard when the
|
|
987
|
-
// current request has no Builder branch project configured
|
|
988
|
-
//
|
|
989
|
-
//
|
|
990
|
-
//
|
|
1071
|
+
// current request has no Builder branch project configured. Hosted
|
|
1072
|
+
// Agent Native deployments submit into the Builder-org Forms waitlist;
|
|
1073
|
+
// local/self-hosted deployments keep the analytics signal without
|
|
1074
|
+
// sending private workspace data to Agent Native.
|
|
991
1075
|
getH3App(nitroApp).use(`${P}/builder/branch-waitlist`, defineEventHandler(async (event) => {
|
|
992
1076
|
if (getMethod(event) !== "POST") {
|
|
993
1077
|
setResponseStatus(event, 405);
|
|
@@ -998,10 +1082,28 @@ export function createCoreRoutesPlugin(options = {}) {
|
|
|
998
1082
|
setResponseStatus(event, 401);
|
|
999
1083
|
return { error: "Authentication required" };
|
|
1000
1084
|
}
|
|
1085
|
+
const body = ((await readBody(event).catch(() => ({}))) ??
|
|
1086
|
+
{});
|
|
1087
|
+
let formSubmission;
|
|
1088
|
+
try {
|
|
1089
|
+
formSubmission = await submitBuilderWaitlistForm(event, session.email, body);
|
|
1090
|
+
}
|
|
1091
|
+
catch (err) {
|
|
1092
|
+
await trackBuilderLifecycle(event, "builder branch waitlist form failed", session.email, {
|
|
1093
|
+
reason: err instanceof Error ? err.message : "unknown_waitlist_error",
|
|
1094
|
+
stage: "waitlist",
|
|
1095
|
+
});
|
|
1096
|
+
setResponseStatus(event, 502);
|
|
1097
|
+
return {
|
|
1098
|
+
error: "Couldn't join the waitlist. Please try again in a moment.",
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1001
1101
|
await trackBuilderLifecycle(event, "builder branch waitlist joined", session.email, {
|
|
1102
|
+
formId: formSubmission.formId ?? null,
|
|
1103
|
+
formSubmitted: formSubmission.submitted,
|
|
1002
1104
|
stage: "waitlist",
|
|
1003
1105
|
});
|
|
1004
|
-
return { ok: true };
|
|
1106
|
+
return { ok: true, formSubmitted: formSubmission.submitted };
|
|
1005
1107
|
}));
|
|
1006
1108
|
getH3App(nitroApp).use(`${P}/builder/callback`, defineEventHandler(async (event) => {
|
|
1007
1109
|
if (getMethod(event) !== "GET") {
|