@agent-native/core 0.68.0 → 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 +18 -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/agent/engine/builder-engine.ts +22 -3
- package/corpus/core/src/agent/engine/types.ts +1 -0
- package/corpus/core/src/agent/production-agent.ts +2 -0
- package/corpus/core/src/agent/types.ts +1 -0
- package/corpus/core/src/cli/pr-visual-recap-workflow.ts +1 -1
- package/corpus/core/src/client/AssistantChat.tsx +45 -6
- package/corpus/core/src/client/CommandMenu.tsx +98 -3
- package/corpus/core/src/client/ConnectBuilderCard.tsx +11 -2
- package/corpus/core/src/client/active-run-state.ts +16 -0
- package/corpus/core/src/client/guided-questions.tsx +73 -17
- package/corpus/core/src/client/index.ts +2 -0
- package/corpus/core/src/client/sse-event-processor.ts +9 -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/core/src/templates/workspace-root/.env.example +4 -0
- 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/actions/show-design-questions.ts +15 -1
- package/corpus/templates/design/app/hooks/use-agent-generating.ts +47 -8
- package/corpus/templates/design/app/pages/DesignEditor.tsx +6 -0
- 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/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +21 -3
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/types.d.ts +2 -0
- package/dist/agent/engine/types.d.ts.map +1 -1
- package/dist/agent/engine/types.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +3 -0
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/types.d.ts +2 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +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/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +42 -7
- package/dist/client/AssistantChat.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/active-run-state.d.ts +2 -0
- package/dist/client/active-run-state.d.ts.map +1 -1
- package/dist/client/active-run-state.js +10 -0
- package/dist/client/active-run-state.js.map +1 -1
- package/dist/client/guided-questions.d.ts +2 -0
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +52 -7
- package/dist/client/guided-questions.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/client/sse-event-processor.d.ts +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +7 -1
- package/dist/client/sse-event-processor.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/dist/templates/workspace-root/.env.example +4 -0
- 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
- package/src/templates/workspace-root/.env.example +4 -0
|
@@ -8,10 +8,16 @@ import {
|
|
|
8
8
|
// legitimately take several minutes, so avoid treating normal latency as
|
|
9
9
|
// failure.
|
|
10
10
|
const GENERATION_ORPHAN_TIMEOUT_MS = 30 * 60_000;
|
|
11
|
+
// Auto-continue briefly sets isRunning=false between gateway continuations.
|
|
12
|
+
// Debounce stop handling so we do not flash "generation complete" mid-turn.
|
|
13
|
+
const CHAT_STOP_DEBOUNCE_MS = 4_000;
|
|
11
14
|
|
|
12
15
|
interface UseAgentGeneratingOptions {
|
|
13
16
|
onComplete?: (tabId: string | null) => void;
|
|
14
17
|
onStale?: (tabId: string | null) => void;
|
|
18
|
+
/** When chat starts on a tab we did not open, adopt it if this returns true. */
|
|
19
|
+
shouldAdoptRunningTab?: () => boolean;
|
|
20
|
+
onAdoptRunningTab?: (tabId: string) => void;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
/**
|
|
@@ -23,9 +29,17 @@ export function useAgentGenerating(options: UseAgentGeneratingOptions = {}) {
|
|
|
23
29
|
const [generating, setGenerating] = useState(false);
|
|
24
30
|
const activeTabIdRef = useRef<string | null>(null);
|
|
25
31
|
const timeoutRef = useRef<number | null>(null);
|
|
32
|
+
const stopDebounceRef = useRef<number | null>(null);
|
|
26
33
|
const callbacksRef = useRef(options);
|
|
27
34
|
callbacksRef.current = options;
|
|
28
35
|
|
|
36
|
+
const clearStopDebounce = useCallback(() => {
|
|
37
|
+
if (stopDebounceRef.current) {
|
|
38
|
+
window.clearTimeout(stopDebounceRef.current);
|
|
39
|
+
stopDebounceRef.current = null;
|
|
40
|
+
}
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
29
43
|
const clearGenerationTimeout = useCallback(() => {
|
|
30
44
|
if (timeoutRef.current) {
|
|
31
45
|
window.clearTimeout(timeoutRef.current);
|
|
@@ -35,9 +49,10 @@ export function useAgentGenerating(options: UseAgentGeneratingOptions = {}) {
|
|
|
35
49
|
|
|
36
50
|
const reset = useCallback(() => {
|
|
37
51
|
clearGenerationTimeout();
|
|
52
|
+
clearStopDebounce();
|
|
38
53
|
activeTabIdRef.current = null;
|
|
39
54
|
setGenerating(false);
|
|
40
|
-
}, [clearGenerationTimeout]);
|
|
55
|
+
}, [clearGenerationTimeout, clearStopDebounce]);
|
|
41
56
|
|
|
42
57
|
const startGenerationTimeout = useCallback(
|
|
43
58
|
(tabId: string | null) => {
|
|
@@ -68,25 +83,49 @@ export function useAgentGenerating(options: UseAgentGeneratingOptions = {}) {
|
|
|
68
83
|
const eventTabId =
|
|
69
84
|
typeof detail.tabId === "string" ? detail.tabId : null;
|
|
70
85
|
|
|
71
|
-
if (!activeTabIdRef.current && detail.isRunning)
|
|
72
|
-
|
|
86
|
+
if (!activeTabIdRef.current && detail.isRunning) {
|
|
87
|
+
if (eventTabId && callbacksRef.current.shouldAdoptRunningTab?.()) {
|
|
88
|
+
activeTabIdRef.current = eventTabId;
|
|
89
|
+
callbacksRef.current.onAdoptRunningTab?.(eventTabId);
|
|
90
|
+
setGenerating(true);
|
|
91
|
+
startGenerationTimeout(eventTabId);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (eventTabId && eventTabId !== activeTabIdRef.current) {
|
|
97
|
+
if (!detail.isRunning && !activeTabIdRef.current) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
73
102
|
|
|
74
103
|
if (!detail.isRunning) {
|
|
75
|
-
|
|
76
|
-
|
|
104
|
+
clearStopDebounce();
|
|
105
|
+
const tabId = activeTabIdRef.current;
|
|
106
|
+
stopDebounceRef.current = window.setTimeout(() => {
|
|
107
|
+
stopDebounceRef.current = null;
|
|
108
|
+
if (activeTabIdRef.current !== tabId) return;
|
|
109
|
+
callbacksRef.current.onComplete?.(tabId);
|
|
110
|
+
reset();
|
|
111
|
+
}, CHAT_STOP_DEBOUNCE_MS);
|
|
77
112
|
return;
|
|
78
113
|
}
|
|
114
|
+
clearStopDebounce();
|
|
79
115
|
setGenerating(true);
|
|
80
116
|
startGenerationTimeout(activeTabIdRef.current);
|
|
81
117
|
}
|
|
82
118
|
};
|
|
83
119
|
window.addEventListener("agentNative.chatRunning", handler);
|
|
84
120
|
return () => window.removeEventListener("agentNative.chatRunning", handler);
|
|
85
|
-
}, [reset, startGenerationTimeout]);
|
|
121
|
+
}, [clearStopDebounce, reset, startGenerationTimeout]);
|
|
86
122
|
|
|
87
123
|
useEffect(() => {
|
|
88
|
-
return () =>
|
|
89
|
-
|
|
124
|
+
return () => {
|
|
125
|
+
clearGenerationTimeout();
|
|
126
|
+
clearStopDebounce();
|
|
127
|
+
};
|
|
128
|
+
}, [clearGenerationTimeout, clearStopDebounce]);
|
|
90
129
|
|
|
91
130
|
const submit = useCallback(
|
|
92
131
|
(
|
|
@@ -428,6 +428,12 @@ export default function DesignEditor() {
|
|
|
428
428
|
} = useAgentGenerating({
|
|
429
429
|
onComplete: handleGenerationComplete,
|
|
430
430
|
onStale: markGenerationStale,
|
|
431
|
+
shouldAdoptRunningTab: () =>
|
|
432
|
+
Boolean(id) && !generationOutputReadyRef.current,
|
|
433
|
+
onAdoptRunningTab: (tabId) => {
|
|
434
|
+
setGenerationChatTabId(tabId);
|
|
435
|
+
setHasPendingGeneration(true);
|
|
436
|
+
},
|
|
431
437
|
});
|
|
432
438
|
const handleQuestionFlowContinue = useCallback(
|
|
433
439
|
(runTabId: string) => {
|
|
@@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button";
|
|
|
4
4
|
|
|
5
5
|
export default function NotFound() {
|
|
6
6
|
return (
|
|
7
|
-
<div className="min-h-
|
|
7
|
+
<div className="flex min-h-full w-full flex-col items-center justify-center bg-background px-4 py-12">
|
|
8
8
|
<h1 className="text-6xl font-bold text-muted-foreground/60 mb-4">404</h1>
|
|
9
9
|
<p className="text-sm text-muted-foreground mb-6">
|
|
10
10
|
The page you are looking for does not exist.
|
|
@@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button";
|
|
|
4
4
|
|
|
5
5
|
export function NotFound() {
|
|
6
6
|
return (
|
|
7
|
-
<div className="flex h-
|
|
7
|
+
<div className="flex min-h-full w-full items-center justify-center bg-background px-4 py-12">
|
|
8
8
|
<div className="text-center">
|
|
9
9
|
<IconMail className="h-12 w-12 text-muted-foreground/40 mx-auto mb-4" />
|
|
10
10
|
<h1 className="text-2xl font-semibold text-foreground">404</h1>
|
|
@@ -380,9 +380,9 @@
|
|
|
380
380
|
--rail-gap: 2rem;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
@
|
|
383
|
+
@container plan-doc (min-width: 64rem) {
|
|
384
384
|
.plan-content-surface[data-plan-layout="wide"] .plan-document-shell {
|
|
385
|
-
--plan-wide-component-width: min(1560px, calc(
|
|
385
|
+
--plan-wide-component-width: min(1560px, calc(100cqw - 5rem));
|
|
386
386
|
}
|
|
387
387
|
|
|
388
388
|
.plan-content-surface[data-plan-layout="wide"] .plan-document-flow-stack {
|
|
@@ -10,7 +10,7 @@ export default function NotFound() {
|
|
|
10
10
|
}, [location.pathname]);
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<div className="min-h-
|
|
13
|
+
<div className="flex min-h-0 w-full flex-1 items-center justify-center bg-background px-4 py-12">
|
|
14
14
|
<div className="text-center">
|
|
15
15
|
<h1 className="text-6xl font-bold text-muted-foreground/40 mb-2">
|
|
16
16
|
404
|
|
@@ -30,19 +30,55 @@ interface GoogleUserInfo {
|
|
|
30
30
|
verified_email?: boolean;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
interface GoogleOAuthCredentials {
|
|
34
|
+
clientId: string;
|
|
35
|
+
clientSecret: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function readCredentialPair(
|
|
39
|
+
clientIdKey: string,
|
|
40
|
+
clientSecretKey: string,
|
|
41
|
+
): GoogleOAuthCredentials | null {
|
|
42
|
+
const clientId = process.env[clientIdKey];
|
|
43
|
+
const clientSecret = process.env[clientSecretKey];
|
|
44
|
+
if (!clientId || !clientSecret) return null;
|
|
45
|
+
return { clientId, clientSecret };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function resolveGoogleProviderCredentialCandidates(): GoogleOAuthCredentials[] {
|
|
49
|
+
const primary = readCredentialPair(
|
|
50
|
+
"GOOGLE_CLIENT_ID",
|
|
51
|
+
"GOOGLE_CLIENT_SECRET",
|
|
52
|
+
);
|
|
53
|
+
const legacy = readCredentialPair(
|
|
54
|
+
"GOOGLE_LEGACY_CLIENT_ID",
|
|
55
|
+
"GOOGLE_LEGACY_CLIENT_SECRET",
|
|
56
|
+
);
|
|
57
|
+
if (!primary) return legacy ? [legacy] : [];
|
|
58
|
+
if (!legacy || legacy.clientId === primary.clientId) return [primary];
|
|
59
|
+
return [primary, legacy];
|
|
60
|
+
}
|
|
61
|
+
|
|
33
62
|
function getOAuthCredentials(): { clientId: string; clientSecret: string } {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
if (!clientId || !clientSecret) {
|
|
63
|
+
const credentials = resolveGoogleProviderCredentialCandidates()[0];
|
|
64
|
+
if (!credentials) {
|
|
37
65
|
throw new Error(
|
|
38
66
|
"Google OAuth is not configured. Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.",
|
|
39
67
|
);
|
|
40
68
|
}
|
|
41
|
-
return
|
|
69
|
+
return credentials;
|
|
42
70
|
}
|
|
43
71
|
|
|
44
72
|
export function isGoogleDocsOAuthConfigured(): boolean {
|
|
45
|
-
return
|
|
73
|
+
return resolveGoogleProviderCredentialCandidates().length > 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isPermanentGoogleRefreshError(error: string | undefined): boolean {
|
|
77
|
+
return (
|
|
78
|
+
error === "invalid_grant" ||
|
|
79
|
+
error === "unauthorized_client" ||
|
|
80
|
+
error === "invalid_client"
|
|
81
|
+
);
|
|
46
82
|
}
|
|
47
83
|
|
|
48
84
|
export function getGooglePickerConfig(): {
|
|
@@ -98,35 +134,55 @@ async function refreshGoogleDocsToken(
|
|
|
98
134
|
throw new Error("Google Docs connection expired. Please reconnect.");
|
|
99
135
|
}
|
|
100
136
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
method: "POST",
|
|
104
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
105
|
-
body: new URLSearchParams({
|
|
106
|
-
refresh_token: tokens.refresh_token,
|
|
107
|
-
client_id: clientId,
|
|
108
|
-
client_secret: clientSecret,
|
|
109
|
-
grant_type: "refresh_token",
|
|
110
|
-
}),
|
|
111
|
-
});
|
|
112
|
-
const data = (await response.json()) as {
|
|
137
|
+
const credentialCandidates = resolveGoogleProviderCredentialCandidates();
|
|
138
|
+
let data: {
|
|
113
139
|
access_token?: string;
|
|
114
140
|
expires_in?: number;
|
|
115
141
|
token_type?: string;
|
|
116
142
|
scope?: string;
|
|
117
143
|
error?: string;
|
|
118
144
|
error_description?: string;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
145
|
+
} | null = null;
|
|
146
|
+
let lastStatusText = "Could not refresh Google token.";
|
|
147
|
+
for (const credentials of credentialCandidates) {
|
|
148
|
+
const response = await fetch(TOKEN_URL, {
|
|
149
|
+
method: "POST",
|
|
150
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
151
|
+
body: new URLSearchParams({
|
|
152
|
+
refresh_token: tokens.refresh_token,
|
|
153
|
+
client_id: credentials.clientId,
|
|
154
|
+
client_secret: credentials.clientSecret,
|
|
155
|
+
grant_type: "refresh_token",
|
|
156
|
+
}),
|
|
157
|
+
});
|
|
158
|
+
lastStatusText = response.statusText;
|
|
159
|
+
data = (await response.json()) as {
|
|
160
|
+
access_token?: string;
|
|
161
|
+
expires_in?: number;
|
|
162
|
+
token_type?: string;
|
|
163
|
+
scope?: string;
|
|
164
|
+
error?: string;
|
|
165
|
+
error_description?: string;
|
|
166
|
+
};
|
|
167
|
+
if (response.ok && data.access_token) break;
|
|
168
|
+
if (!isPermanentGoogleRefreshError(data.error)) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
data.error_description ||
|
|
171
|
+
data.error ||
|
|
172
|
+
"Could not refresh Google token.",
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!data?.access_token) {
|
|
178
|
+
if (isPermanentGoogleRefreshError(data?.error)) {
|
|
126
179
|
await deleteOAuthTokens(GOOGLE_DOCS_PROVIDER, accountId);
|
|
127
180
|
}
|
|
128
181
|
throw new Error(
|
|
129
|
-
data
|
|
182
|
+
data?.error_description ||
|
|
183
|
+
data?.error ||
|
|
184
|
+
lastStatusText ||
|
|
185
|
+
"Could not refresh Google token.",
|
|
130
186
|
);
|
|
131
187
|
}
|
|
132
188
|
|
|
@@ -12,7 +12,7 @@ const NotFound = () => {
|
|
|
12
12
|
}, [location.pathname]);
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
|
-
<div className="min-h-
|
|
15
|
+
<div className="flex min-h-full w-full items-center justify-center bg-background px-4 py-12">
|
|
16
16
|
<div className="text-center">
|
|
17
17
|
<h1 className="text-5xl font-bold text-muted-foreground/30 mb-3">
|
|
18
18
|
404
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder-engine.d.ts","sourceRoot":"","sources":["../../../src/agent/engine/builder-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAwBpB,eAAO,MAAM,oBAAoB,EAAE,kBAMlC,CAAC;AAEF,eAAO,MAAM,wBAAwB,wOAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"builder-engine.d.ts","sourceRoot":"","sources":["../../../src/agent/engine/builder-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAwBpB,eAAO,MAAM,oBAAoB,EAAE,kBAMlC,CAAC;AAEF,eAAO,MAAM,wBAAwB,wOAAuC,CAAC;AAW7E,eAAO,MAAM,qBAAqB,qBAAoC,CAAC;AA+qBvE,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACpC,WAAW,CAEb"}
|
|
@@ -33,6 +33,8 @@ export const BUILDER_SUPPORTED_MODELS = BUILDER_MODEL_CONFIG.supportedModels;
|
|
|
33
33
|
// (Netlify synchronous Functions are 60s) hard-kill the invocation.
|
|
34
34
|
const DEFAULT_BUILDER_GATEWAY_TIMEOUT_MS = 45_000;
|
|
35
35
|
const MAX_BUILDER_GATEWAY_TIMEOUT_MS = 45_000;
|
|
36
|
+
/** Local ai-services has no serverless wall; allow longer streams in dev. */
|
|
37
|
+
const MAX_LOCAL_BUILDER_GATEWAY_TIMEOUT_MS = 180_000;
|
|
36
38
|
const BUILDER_GATEWAY_NETWORK_ERROR_CODE = "builder_gateway_network_error";
|
|
37
39
|
export const BUILDER_DEFAULT_MODEL = BUILDER_MODEL_CONFIG.defaultModel;
|
|
38
40
|
/**
|
|
@@ -442,6 +444,9 @@ async function* parseJsonlStream(reader, model, captureContext = {}) {
|
|
|
442
444
|
: "",
|
|
443
445
|
};
|
|
444
446
|
break;
|
|
447
|
+
case "heartbeat":
|
|
448
|
+
yield { type: "gateway-heartbeat" };
|
|
449
|
+
break;
|
|
445
450
|
case "tool-call": {
|
|
446
451
|
flushPending();
|
|
447
452
|
parts.push({
|
|
@@ -640,15 +645,28 @@ function htmlToText(html) {
|
|
|
640
645
|
export function createBuilderEngine(_config = {}) {
|
|
641
646
|
return new BuilderEngine();
|
|
642
647
|
}
|
|
648
|
+
function resolveMaxBuilderGatewayTimeoutMs() {
|
|
649
|
+
try {
|
|
650
|
+
const base = getBuilderGatewayBaseUrl();
|
|
651
|
+
if (/^https?:\/\/(localhost|127\.0\.0\.1)([:/]|$)/i.test(base)) {
|
|
652
|
+
return MAX_LOCAL_BUILDER_GATEWAY_TIMEOUT_MS;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
catch {
|
|
656
|
+
// ignore malformed override
|
|
657
|
+
}
|
|
658
|
+
return MAX_BUILDER_GATEWAY_TIMEOUT_MS;
|
|
659
|
+
}
|
|
643
660
|
function getBuilderGatewayTimeoutMs() {
|
|
644
661
|
const raw = process.env.AGENT_NATIVE_BUILDER_GATEWAY_TIMEOUT_MS;
|
|
662
|
+
const maxMs = resolveMaxBuilderGatewayTimeoutMs();
|
|
645
663
|
if (!raw)
|
|
646
|
-
return
|
|
664
|
+
return maxMs;
|
|
647
665
|
const parsed = Number(raw);
|
|
648
666
|
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
649
|
-
return
|
|
667
|
+
return maxMs;
|
|
650
668
|
}
|
|
651
|
-
return Math.min(parsed,
|
|
669
|
+
return Math.min(parsed, maxMs);
|
|
652
670
|
}
|
|
653
671
|
function createGatewayAbortSignal(parentSignal, timeoutMs) {
|
|
654
672
|
const controller = new AbortController();
|