@agent-native/core 0.189.0 → 0.190.0-nightly-20260925211446
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/analysis-workspace/SKILL.md +10 -0
- package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +1 -1
- package/corpus/templates/analytics/AGENTS.md +11 -22
- package/corpus/templates/analytics/actions/list-data-dictionary.ts +7 -9
- package/corpus/templates/analytics/actions/search-analytics-query-catalog.ts +1 -1
- package/corpus/templates/analytics/app/components/AnalyticsReviewArtifactPreview.tsx +201 -0
- package/corpus/templates/analytics/app/i18n/en-US.ts +2 -0
- package/corpus/templates/analytics/app/pages/Settings.tsx +50 -3
- package/corpus/templates/analytics/changelog/2026-09-25-first-run-onboarding-records-setup-choices-and-builder-conne.md +6 -0
- package/corpus/templates/analytics/changelog/2026-09-25-human-review-previews-analytics-dashboards-as-real-charts.md +6 -0
- package/corpus/templates/analytics/changelog/2026-09-25-org-admins-can-review-agent-runs-from-settings.md +6 -0
- package/corpus/templates/analytics/changelog/2026-09-25-proactive-query-context.md +6 -0
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +98 -2
- package/corpus/templates/analytics/server/lib/analytics-agent-context.ts +557 -0
- package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +217 -46
- package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +2 -2
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +39 -5
- package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +4 -0
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +268 -2
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +44 -9
- package/corpus/templates/calendar/AGENTS.md +5 -0
- package/corpus/templates/calendar/CHANGELOG.md +6 -0
- package/corpus/templates/calendar/actions/get-event-rules-status.ts +47 -0
- package/corpus/templates/calendar/actions/list-events.ts +50 -4
- package/corpus/templates/calendar/actions/undo-calendar-event-rule.ts +229 -0
- package/corpus/templates/calendar/actions/update-settings.ts +8 -0
- package/corpus/templates/calendar/app/i18n/en-US.ts +27 -0
- package/corpus/templates/calendar/app/pages/Settings.tsx +196 -1
- package/corpus/templates/calendar/changelog/2026-09-25-calendar-feeds-with-the-same-url-keep-their-own-names-and-co.md +6 -0
- package/corpus/templates/calendar/changelog/2026-09-25-calendar-invitation-rules-surface-expired-connections-and-un.md +6 -0
- package/corpus/templates/calendar/changelog/2026-09-25-restore-locally-hidden-events-from-activity-after-disconnect.md +6 -0
- package/corpus/templates/calendar/server/lib/calendar-settings.ts +44 -10
- package/corpus/templates/calendar/server/lib/google-api.ts +15 -1
- package/corpus/templates/calendar/server/lib/google-calendar.ts +1 -1
- package/corpus/templates/calendar/server/plugins/event-rules.ts +628 -0
- package/corpus/templates/calendar/shared/api.ts +13 -0
- package/corpus/templates/calendar/shared/settings.ts +71 -1
- package/corpus/templates/clips/actions/create-recording.ts +83 -2
- package/corpus/templates/clips/actions/finalize-recording.ts +610 -110
- package/corpus/templates/clips/actions/get-recording-player-data.ts +6 -0
- package/corpus/templates/clips/actions/import-loom-recording.ts +2 -0
- package/corpus/templates/clips/actions/lib/create-recording-schema.ts +7 -0
- package/corpus/templates/clips/actions/lib/loom-import-job.ts +15 -1
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +126 -26
- package/corpus/templates/clips/app/hooks/use-drop-video-upload.ts +75 -15
- package/corpus/templates/clips/app/routes/_app.r.$recordingId.tsx +5 -1
- package/corpus/templates/clips/app/routes/record.tsx +134 -40
- package/corpus/templates/clips/chrome-extension/src/background.ts +3 -0
- package/corpus/templates/clips/chrome-extension/src/offscreen.ts +73 -16
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +188 -18
- package/corpus/templates/clips/desktop/src/lib/recording-request.ts +1 -0
- package/corpus/templates/clips/server/db/schema.ts +4 -0
- package/corpus/templates/clips/server/jobs/media-verification.ts +78 -4
- package/corpus/templates/clips/server/jobs/recording-failure-backfill.ts +142 -0
- package/corpus/templates/clips/server/lib/media-verification-state.ts +29 -0
- package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +2 -0
- package/corpus/templates/clips/server/lib/recording-failures.ts +111 -0
- package/corpus/templates/clips/server/lib/recordings.ts +6 -1
- package/corpus/templates/clips/server/lib/s3-upload-provider.ts +8 -3
- package/corpus/templates/clips/server/lib/upload-lease.ts +25 -6
- package/corpus/templates/clips/server/plugins/calendar-jobs.ts +2 -0
- package/corpus/templates/clips/server/plugins/db.ts +18 -0
- package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +48 -5
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/abort.post.ts +322 -31
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +223 -61
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/interrupt.post.ts +62 -4
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/reset-chunks.post.ts +74 -7
- package/corpus/templates/clips/shared/recording-core.ts +27 -0
- package/corpus/templates/design/actions/get-design.ts +35 -6
- package/corpus/templates/mail/.agents/skills/inbox-automations/SKILL.md +4 -0
- package/corpus/templates/mail/actions/consolidate-ai-filter-rules.ts +41 -0
- package/corpus/templates/mail/actions/get-ai-priority.ts +48 -8
- package/corpus/templates/mail/actions/record-ai-priority-feedback.ts +69 -0
- package/corpus/templates/mail/actions/update-mail-preferences.ts +2 -0
- package/corpus/templates/mail/app/components/email/EmailList.tsx +179 -32
- package/corpus/templates/mail/app/components/email/EmailListItem.tsx +97 -9
- package/corpus/templates/mail/app/components/email/EmailThread.tsx +55 -1
- package/corpus/templates/mail/app/components/email/ImportanceFeedbackMenu.tsx +52 -0
- package/corpus/templates/mail/app/components/email/compose-autocomplete.ts +2 -1
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +219 -188
- package/corpus/templates/mail/app/components/onboarding/AiInboxSetup.tsx +338 -0
- package/corpus/templates/mail/app/components/settings/AiFilterSection.tsx +597 -781
- package/corpus/templates/mail/app/components/settings/AiRulePromptField.tsx +37 -0
- package/corpus/templates/mail/app/global.css +42 -26
- package/corpus/templates/mail/app/hooks/use-ai-priority-feedback.ts +43 -0
- package/corpus/templates/mail/app/hooks/use-automations.ts +23 -0
- package/corpus/templates/mail/app/i18n/en-US.ts +58 -3
- package/corpus/templates/mail/app/pages/InboxPage.tsx +47 -10
- package/corpus/templates/mail/changelog/2026-09-25-editing-importance-rules-preserves-disabled-instructions-and.md +6 -0
- package/corpus/templates/mail/changelog/2026-09-25-handle-astral-unicode-letters-in-autocomplete-word-boundarie.md +6 -0
- package/corpus/templates/mail/changelog/2026-09-25-jev-priority-feedback-and-inbox-settings.md +6 -0
- package/corpus/templates/mail/changelog/2026-09-25-keep-existing-ai-filter-rules-intact-when-saving-a-prompt.md +6 -0
- package/corpus/templates/mail/server/lib/automation-engine.ts +21 -12
- package/corpus/templates/mail/server/lib/automations.ts +100 -1
- package/corpus/templates/mail/shared/types.ts +3 -0
- package/corpus/templates/plan/app/i18n/en-US.ts +6 -0
- package/corpus/templates/plan/app/lib/plan-invite-suggestion.ts +43 -0
- package/corpus/templates/plan/app/pages/PlansPage.tsx +249 -4
- package/corpus/templates/slides/actions/create-deck.ts +11 -1
- package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +117 -1
- package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +373 -330
- package/corpus/templates/slides/app/components/design-system/builder-index-response.ts +36 -5
- package/corpus/templates/slides/app/components/editor/BlockBubbleMenu.tsx +21 -53
- package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +347 -671
- package/corpus/templates/slides/app/components/editor/bullet-editing.ts +55 -8
- package/corpus/templates/slides/app/components/editor/in-place-text-session.ts +2082 -0
- package/corpus/templates/slides/app/components/editor/list-editing.ts +174 -16
- package/corpus/templates/slides/app/components/editor/rich-text-selection.ts +497 -62
- package/corpus/templates/slides/app/components/editor/slide-text-targets.ts +102 -20
- package/corpus/templates/slides/app/context/DeckContext.tsx +9 -4
- package/corpus/templates/slides/app/global.css +7 -219
- package/corpus/templates/slides/app/i18n/en-US.ts +3 -0
- package/corpus/templates/slides/app/lib/sanitize-slide-html.ts +7 -0
- package/corpus/templates/slides/app/lib/slide-image-replacement.ts +203 -1
- package/corpus/templates/slides/app/lib/slide-source-map.ts +43 -0
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +182 -4
- package/corpus/templates/slides/app/routes/settings.tsx +33 -2
- package/corpus/templates/slides/changelog/2026-09-25-improve-slides-design-system-setup-feedback.md +6 -0
- package/corpus/templates/slides/changelog/2026-09-25-org-admins-can-review-agent-runs-from-settings.md +6 -0
- package/corpus/templates/slides/changelog/2026-09-25-text-on-a-slide-is-now-edited-in-place-clicking-into-it-chan.md +6 -0
- package/corpus/templates/slides/package.json +0 -12
- package/corpus/templates/slides/scripts/edit-fidelity/README.md +4 -2
- package/corpus/templates/slides/scripts/edit-fidelity/run.ts +12 -3
- package/corpus/templates/slides/vite.config.ts +1 -10
- package/dist/agent/jev-tool-prefetch.d.ts +29 -3
- package/dist/agent/jev-tool-prefetch.js +161 -34
- package/dist/agent/production-agent.d.ts +11 -0
- package/dist/agent/production-agent.js +39 -8
- package/dist/app-config/runtime.d.ts +1 -0
- package/dist/app-config/runtime.js +4 -0
- package/dist/app-config/schema.d.ts +1 -0
- package/dist/client/AgentSidebar.d.ts +3 -1
- package/dist/client/AgentSidebar.js +8 -12
- package/dist/client/analytics/index.d.ts +1 -1
- package/dist/client/analytics/index.js +1 -1
- package/dist/client/analytics.d.ts +2 -0
- package/dist/client/analytics.js +9 -0
- package/dist/client/api-path.js +5 -2
- package/dist/client/chat/run-recovery.d.ts +0 -3
- package/dist/client/chat/run-recovery.js +13 -23
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/observability/ObservabilityDashboard.d.ts +3 -0
- package/dist/client/observability/ObservabilityDashboard.js +366 -71
- package/dist/client/observability/ObservabilityReviewSummaryButton.d.ts +4 -1
- package/dist/client/observability/ObservabilityReviewSummaryButton.js +13 -9
- package/dist/client/observability/OutputPreview.d.ts +9 -4
- package/dist/client/observability/OutputPreview.js +230 -52
- package/dist/client/onboarding/FirstRunOnboarding.js +67 -4
- package/dist/client/onboarding/use-onboarding.js +2 -0
- package/dist/client/sharing/ShareButton.d.ts +2 -0
- package/dist/client/sharing/ShareButton.js +1 -0
- package/dist/client/sharing/useShareButtonController.d.ts +1 -0
- package/dist/client/sharing/useShareButtonController.js +29 -8
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.js +9 -1
- package/dist/embeddings/index.d.ts +3 -1
- package/dist/embeddings/index.js +20 -10
- package/dist/jobs/sweep-hooks.d.ts +7 -0
- package/dist/jobs/sweep-hooks.js +28 -0
- package/dist/localization/default-messages.d.ts +1 -0
- package/dist/localization/default-messages.js +1 -0
- package/dist/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/actions/authorization.d.ts +1 -0
- package/dist/observability/actions/authorization.js +22 -0
- package/dist/observability/actions/get-observability-review-detail.d.ts +5 -0
- package/dist/observability/actions/get-observability-review-detail.js +10 -2
- package/dist/observability/actions/get-observability-review-summary-source.d.ts +2 -0
- package/dist/observability/actions/get-observability-review-summary-source.js +3 -2
- package/dist/observability/actions/save-observability-instruction-update.js +2 -1
- package/dist/observability/actions/save-observability-review-summary.js +21 -10
- package/dist/observability/migrations.js +25 -0
- package/dist/observability/reviews.d.ts +3 -1
- package/dist/observability/reviews.js +410 -53
- package/dist/observability/routes.d.ts +6 -6
- package/dist/observability/store.d.ts +15 -0
- package/dist/observability/store.js +131 -11
- package/dist/observability/types.d.ts +18 -0
- package/dist/org/handlers.d.ts +1 -1
- package/dist/org/index.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
- package/dist/provider-api/actions/provider-api.d.ts +8 -8
- package/dist/secrets/routes.d.ts +3 -3
- package/dist/server/agent-chat/plugin-options.d.ts +4 -20
- package/dist/server/agent-chat/prompt-resources.d.ts +16 -0
- package/dist/server/agent-chat/prompt-resources.js +385 -22
- package/dist/server/agent-chat-plugin.d.ts +3 -1
- package/dist/server/agent-chat-plugin.js +149 -27
- package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +3 -0
- package/dist/server/prompts/framework-core-compact.js +1 -1
- package/dist/server/prompts/framework-core.js +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/request-context.d.ts +6 -3
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/settings/org-settings.d.ts +4 -2
- package/dist/settings/org-settings.js +3 -3
- package/dist/settings/store.d.ts +3 -1
- package/dist/settings/store.js +8 -3
- package/dist/styles/agent-native.css +5 -0
- package/dist/templates/default/app/i18n/ar-SA.ts +1 -0
- package/dist/templates/default/app/i18n/de-DE.ts +1 -0
- package/dist/templates/default/app/i18n/en-US.ts +1 -0
- package/dist/templates/default/app/i18n/es-ES.ts +1 -0
- package/dist/templates/default/app/i18n/fr-FR.ts +1 -0
- package/dist/templates/default/app/i18n/hi-IN.ts +1 -0
- package/dist/templates/default/app/i18n/ja-JP.ts +1 -0
- package/dist/templates/default/app/i18n/ko-KR.ts +1 -0
- package/dist/templates/default/app/i18n/pt-BR.ts +1 -0
- package/dist/templates/default/app/i18n/zh-CN.ts +1 -0
- package/dist/templates/default/app/i18n/zh-TW.ts +1 -0
- package/dist/tracking/registry.js +11 -4
- package/package.json +4 -3
- package/src/templates/default/app/i18n/ar-SA.ts +1 -0
- package/src/templates/default/app/i18n/de-DE.ts +1 -0
- package/src/templates/default/app/i18n/en-US.ts +1 -0
- package/src/templates/default/app/i18n/es-ES.ts +1 -0
- package/src/templates/default/app/i18n/fr-FR.ts +1 -0
- package/src/templates/default/app/i18n/hi-IN.ts +1 -0
- package/src/templates/default/app/i18n/ja-JP.ts +1 -0
- package/src/templates/default/app/i18n/ko-KR.ts +1 -0
- package/src/templates/default/app/i18n/pt-BR.ts +1 -0
- package/src/templates/default/app/i18n/zh-CN.ts +1 -0
- package/src/templates/default/app/i18n/zh-TW.ts +1 -0
- package/corpus/templates/slides/app/components/editor/SlideBubbleMenu.tsx +0 -488
- package/corpus/templates/slides/app/components/editor/SlideInlineEditor.tsx +0 -589
- package/corpus/templates/slides/app/components/editor/SlideRichTextEditor.tsx +0 -1347
- package/corpus/templates/slides/app/components/editor/SlideSlashMenu.tsx +0 -373
|
@@ -25,15 +25,6 @@ export default defineConfig({
|
|
|
25
25
|
}),
|
|
26
26
|
],
|
|
27
27
|
optimizeDeps: {
|
|
28
|
-
include: [
|
|
29
|
-
"@tiptap/core",
|
|
30
|
-
"@tiptap/react",
|
|
31
|
-
"@tiptap/starter-kit",
|
|
32
|
-
"@tiptap/extension-collaboration",
|
|
33
|
-
"@tiptap/extension-collaboration-caret",
|
|
34
|
-
"@tiptap/y-tiptap",
|
|
35
|
-
"yjs",
|
|
36
|
-
"y-protocols/awareness",
|
|
37
|
-
],
|
|
28
|
+
include: ["yjs", "y-protocols/awareness"],
|
|
38
29
|
},
|
|
39
30
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type BuilderGatewayAuth } from "../server/credential-provider.js";
|
|
2
2
|
import type { EngineTool } from "./engine/types.js";
|
|
3
3
|
import type { ActionEntry, JevContextCredentials } from "./production-agent.js";
|
|
4
|
+
import type { AgentChatStructuredMessage, AgentMessage } from "./types.js";
|
|
5
|
+
export declare const JEV_TIMEOUT_MS = 750;
|
|
4
6
|
type JevChoiceAnswer = {
|
|
5
7
|
choice?: unknown;
|
|
6
8
|
probabilities?: unknown;
|
|
@@ -25,21 +27,45 @@ export interface JevRankCandidatesOptions {
|
|
|
25
27
|
apiKey?: string;
|
|
26
28
|
personalApiKey?: string;
|
|
27
29
|
builderAuth?: BuilderGatewayAuth | null;
|
|
30
|
+
/** IDs, descriptions, and metadata are sent to Jev; callers provide summaries only. */
|
|
28
31
|
candidates: readonly JevCandidate[];
|
|
29
32
|
candidateStateKey: string;
|
|
30
33
|
answerKey: string;
|
|
31
34
|
question: string;
|
|
32
35
|
limit?: number;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface JevCandidateRanking {
|
|
40
|
+
status: "selected" | "no-match" | "unavailable";
|
|
41
|
+
ids: string[];
|
|
33
42
|
}
|
|
43
|
+
/** Keep Jev grounded in recent user requests without sending assistant results. */
|
|
44
|
+
export declare function buildJevRequestContext(input: {
|
|
45
|
+
request: string;
|
|
46
|
+
history?: readonly AgentMessage[];
|
|
47
|
+
structuredHistory?: readonly AgentChatStructuredMessage[];
|
|
48
|
+
}): string;
|
|
49
|
+
/** Current request plus the last two user turns for semantic/catalog retrieval. */
|
|
50
|
+
export declare function buildRecentUserRequestContext(input: {
|
|
51
|
+
request: string;
|
|
52
|
+
history?: readonly AgentMessage[];
|
|
53
|
+
structuredHistory?: readonly AgentChatStructuredMessage[];
|
|
54
|
+
}): string;
|
|
34
55
|
/**
|
|
35
|
-
* Rank a bounded metadata-only catalog with Jev.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
56
|
+
* Rank a bounded metadata-only catalog with Jev. Direct keys send bounded
|
|
57
|
+
* request text and candidate IDs, descriptions, and metadata to a third party;
|
|
58
|
+
* callers must omit paths, raw bodies, SQL, tool inputs/results, and row data.
|
|
59
|
+
* A missing key, malformed response, timeout, or provider failure returns no
|
|
60
|
+
* ranking so callers keep their existing deterministic fallback.
|
|
38
61
|
*/
|
|
39
62
|
export declare function rankJevCandidates(options: JevRankCandidatesOptions): Promise<string[]>;
|
|
63
|
+
export declare function rankJevCandidatesWithStatus(options: JevRankCandidatesOptions): Promise<JevCandidateRanking>;
|
|
40
64
|
export declare function shortlistJevCandidates<T extends JevCandidate>(request: string, candidates: readonly T[]): T[];
|
|
41
65
|
export interface JevToolPrefetchOptions {
|
|
42
66
|
request: string;
|
|
67
|
+
skip?: boolean;
|
|
68
|
+
deadlineAt?: number;
|
|
43
69
|
apiKey?: string;
|
|
44
70
|
personalApiKey?: string;
|
|
45
71
|
builderAuth?: BuilderGatewayAuth | null;
|
|
@@ -4,25 +4,121 @@ import { searchToolRegistry, TOOL_SEARCH_ACTION_NAME } from "./tool-search.js";
|
|
|
4
4
|
const MAX_JEV_CANDIDATES = 128;
|
|
5
5
|
const DEFAULT_PREFETCH_LIMIT = 3;
|
|
6
6
|
const MAX_PREFETCH_LIMIT = 5;
|
|
7
|
-
const JEV_TIMEOUT_MS = 750;
|
|
7
|
+
export const JEV_TIMEOUT_MS = 750;
|
|
8
8
|
const JEV_MODEL = "jev-latest";
|
|
9
|
+
const MAX_JEV_THREAD_CONTEXT_CHARS = 6_000;
|
|
10
|
+
const MAX_JEV_PRIOR_USER_MESSAGES = 4;
|
|
11
|
+
const MAX_JEV_PRIOR_MESSAGE_CHARS = 1_100;
|
|
12
|
+
const MAX_JEV_CURRENT_MESSAGE_CHARS = 3_600;
|
|
13
|
+
const MAX_RETRIEVAL_CONTEXT_CHARS = 3_600;
|
|
14
|
+
const MAX_RETRIEVAL_PRIOR_USER_MESSAGES = 2;
|
|
15
|
+
const MAX_RETRIEVAL_PRIOR_MESSAGE_CHARS = 900;
|
|
16
|
+
function compactJevText(value, maxChars) {
|
|
17
|
+
const text = value.replace(/\s+/g, " ").trim();
|
|
18
|
+
if (text.length <= maxChars)
|
|
19
|
+
return text;
|
|
20
|
+
const ellipsis = " … ";
|
|
21
|
+
const startChars = Math.ceil((maxChars - ellipsis.length) * 0.75);
|
|
22
|
+
return `${text.slice(0, startChars)}${ellipsis}${text.slice(-(maxChars - startChars - ellipsis.length))}`;
|
|
23
|
+
}
|
|
24
|
+
function visiblePriorMessages(input) {
|
|
25
|
+
const structured = Array.isArray(input.structuredHistory)
|
|
26
|
+
? input.structuredHistory.flatMap((message) => {
|
|
27
|
+
if (!message ||
|
|
28
|
+
(message.role !== "user" && message.role !== "assistant") ||
|
|
29
|
+
!Array.isArray(message.content)) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const text = message.content
|
|
33
|
+
.flatMap((part) => part?.type === "text" && typeof part.text === "string"
|
|
34
|
+
? [part.text]
|
|
35
|
+
: [])
|
|
36
|
+
.join(" ")
|
|
37
|
+
.trim();
|
|
38
|
+
return text ? [{ role: message.role, content: text }] : [];
|
|
39
|
+
})
|
|
40
|
+
: [];
|
|
41
|
+
return Array.isArray(input.structuredHistory)
|
|
42
|
+
? structured
|
|
43
|
+
: (Array.isArray(input.history) ? input.history : []).flatMap((message) => message &&
|
|
44
|
+
(message.role === "user" || message.role === "assistant") &&
|
|
45
|
+
typeof message.content === "string" &&
|
|
46
|
+
message.content.trim()
|
|
47
|
+
? [{ role: message.role, content: message.content }]
|
|
48
|
+
: []);
|
|
49
|
+
}
|
|
50
|
+
/** Keep Jev grounded in recent user requests without sending assistant results. */
|
|
51
|
+
export function buildJevRequestContext(input) {
|
|
52
|
+
const priorMessages = visiblePriorMessages(input);
|
|
53
|
+
const current = compactJevText(input.request, MAX_JEV_CURRENT_MESSAGE_CHARS);
|
|
54
|
+
const currentBlock = `Current request:\n${current}`;
|
|
55
|
+
let remaining = MAX_JEV_THREAD_CONTEXT_CHARS - currentBlock.length - 40;
|
|
56
|
+
const recentLines = [];
|
|
57
|
+
const priorUsers = priorMessages.filter((message) => message.role === "user");
|
|
58
|
+
const selectedMessages = priorUsers.slice(-MAX_JEV_PRIOR_USER_MESSAGES);
|
|
59
|
+
for (const message of selectedMessages.reverse()) {
|
|
60
|
+
if (remaining < 80)
|
|
61
|
+
break;
|
|
62
|
+
const content = compactJevText(message.content, Math.min(MAX_JEV_PRIOR_MESSAGE_CHARS, remaining - 12));
|
|
63
|
+
const line = `User: ${content}`;
|
|
64
|
+
if (line.length > remaining)
|
|
65
|
+
break;
|
|
66
|
+
recentLines.push(line);
|
|
67
|
+
remaining -= line.length + 1;
|
|
68
|
+
}
|
|
69
|
+
const recent = recentLines.reverse();
|
|
70
|
+
return recent.length
|
|
71
|
+
? `Recent conversation:\n${recent.join("\n")}\n\n${currentBlock}`
|
|
72
|
+
: currentBlock;
|
|
73
|
+
}
|
|
74
|
+
/** Current request plus the last two user turns for semantic/catalog retrieval. */
|
|
75
|
+
export function buildRecentUserRequestContext(input) {
|
|
76
|
+
const priorUsers = visiblePriorMessages(input)
|
|
77
|
+
.filter((message) => message.role === "user")
|
|
78
|
+
.slice(-MAX_RETRIEVAL_PRIOR_USER_MESSAGES);
|
|
79
|
+
const current = compactJevText(input.request, MAX_JEV_CURRENT_MESSAGE_CHARS);
|
|
80
|
+
const currentBlock = `Current request:\n${current}`;
|
|
81
|
+
let remaining = MAX_RETRIEVAL_CONTEXT_CHARS - currentBlock.length - 32;
|
|
82
|
+
const recentLines = [];
|
|
83
|
+
for (const message of priorUsers.reverse()) {
|
|
84
|
+
if (remaining < 80)
|
|
85
|
+
break;
|
|
86
|
+
const content = compactJevText(message.content, Math.min(MAX_RETRIEVAL_PRIOR_MESSAGE_CHARS, remaining - 12));
|
|
87
|
+
const line = `User: ${content}`;
|
|
88
|
+
if (line.length > remaining)
|
|
89
|
+
break;
|
|
90
|
+
recentLines.push(line);
|
|
91
|
+
remaining -= line.length + 1;
|
|
92
|
+
}
|
|
93
|
+
const recent = recentLines.reverse();
|
|
94
|
+
return recent.length
|
|
95
|
+
? `Recent user requests:\n${recent.join("\n")}\n\n${currentBlock}`
|
|
96
|
+
: currentBlock;
|
|
97
|
+
}
|
|
9
98
|
/**
|
|
10
|
-
* Rank a bounded metadata-only catalog with Jev.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
99
|
+
* Rank a bounded metadata-only catalog with Jev. Direct keys send bounded
|
|
100
|
+
* request text and candidate IDs, descriptions, and metadata to a third party;
|
|
101
|
+
* callers must omit paths, raw bodies, SQL, tool inputs/results, and row data.
|
|
102
|
+
* A missing key, malformed response, timeout, or provider failure returns no
|
|
103
|
+
* ranking so callers keep their existing deterministic fallback.
|
|
13
104
|
*/
|
|
14
105
|
export async function rankJevCandidates(options) {
|
|
106
|
+
return (await rankJevCandidatesWithStatus(options)).ids;
|
|
107
|
+
}
|
|
108
|
+
export async function rankJevCandidatesWithStatus(options) {
|
|
15
109
|
const request = options.request.trim();
|
|
16
110
|
const apiKey = options.personalApiKey?.trim();
|
|
17
111
|
const builderAuth = options.builderAuth;
|
|
18
112
|
if (!request ||
|
|
19
113
|
(!apiKey && !builderAuth) ||
|
|
20
|
-
options.candidates.length === 0
|
|
21
|
-
|
|
114
|
+
options.candidates.length === 0 ||
|
|
115
|
+
options.signal?.aborted ||
|
|
116
|
+
(options.timeoutMs !== undefined && options.timeoutMs <= 0)) {
|
|
117
|
+
return { status: "unavailable", ids: [] };
|
|
22
118
|
}
|
|
23
119
|
const candidates = shortlistJevCandidates(request, options.candidates);
|
|
24
120
|
if (candidates.length === 0)
|
|
25
|
-
return [];
|
|
121
|
+
return { status: "unavailable", ids: [] };
|
|
26
122
|
const limit = Math.max(1, Math.min(options.limit ?? DEFAULT_PREFETCH_LIMIT, MAX_PREFETCH_LIMIT));
|
|
27
123
|
try {
|
|
28
124
|
let noMatchId = "__no_match__";
|
|
@@ -57,10 +153,13 @@ export async function rankJevCandidates(options) {
|
|
|
57
153
|
personalApiKey: options.personalApiKey,
|
|
58
154
|
builderAuth,
|
|
59
155
|
request: jevRequest,
|
|
156
|
+
signal: options.signal,
|
|
157
|
+
timeoutMs: options.timeoutMs,
|
|
60
158
|
});
|
|
61
159
|
const answer = response.answers?.[options.answerKey];
|
|
62
|
-
if (answer?.choice === noMatchId)
|
|
63
|
-
return [];
|
|
160
|
+
if (answer?.choice === noMatchId) {
|
|
161
|
+
return { status: "no-match", ids: [] };
|
|
162
|
+
}
|
|
64
163
|
const probabilities = answer?.probabilities && typeof answer.probabilities === "object"
|
|
65
164
|
? answer.probabilities
|
|
66
165
|
: {};
|
|
@@ -69,7 +168,7 @@ export async function rankJevCandidates(options) {
|
|
|
69
168
|
!Number.isFinite(noMatchProbability) ||
|
|
70
169
|
noMatchProbability < 0 ||
|
|
71
170
|
noMatchProbability > 1) {
|
|
72
|
-
return [];
|
|
171
|
+
return { status: "unavailable", ids: [] };
|
|
73
172
|
}
|
|
74
173
|
for (const candidate of candidates) {
|
|
75
174
|
const probability = probabilities[candidate.id];
|
|
@@ -78,10 +177,10 @@ export async function rankJevCandidates(options) {
|
|
|
78
177
|
!Number.isFinite(probability) ||
|
|
79
178
|
probability < 0 ||
|
|
80
179
|
probability > 1)) {
|
|
81
|
-
return [];
|
|
180
|
+
return { status: "unavailable", ids: [] };
|
|
82
181
|
}
|
|
83
182
|
}
|
|
84
|
-
|
|
183
|
+
const ids = candidates
|
|
85
184
|
.filter((candidate) => typeof probabilities[candidate.id] === "number" &&
|
|
86
185
|
probabilities[candidate.id] > noMatchProbability)
|
|
87
186
|
.map((candidate) => ({
|
|
@@ -91,10 +190,13 @@ export async function rankJevCandidates(options) {
|
|
|
91
190
|
.sort((a, b) => b.probability - a.probability || a.name.localeCompare(b.name))
|
|
92
191
|
.map((candidate) => candidate.name)
|
|
93
192
|
.slice(0, limit);
|
|
193
|
+
return ids.length > 0
|
|
194
|
+
? { status: "selected", ids }
|
|
195
|
+
: { status: "no-match", ids: [] };
|
|
94
196
|
}
|
|
95
197
|
catch (error) {
|
|
96
198
|
console.warn("[agent] Jev context prefetch unavailable; continuing with the existing context.", error instanceof Error ? error.message : "unknown error");
|
|
97
|
-
return [];
|
|
199
|
+
return { status: "unavailable", ids: [] };
|
|
98
200
|
}
|
|
99
201
|
}
|
|
100
202
|
export function shortlistJevCandidates(request, candidates) {
|
|
@@ -122,6 +224,8 @@ export function shortlistJevCandidates(request, candidates) {
|
|
|
122
224
|
* Jev is an accelerator, not a dependency of agent execution.
|
|
123
225
|
*/
|
|
124
226
|
export async function preloadJevTools(options) {
|
|
227
|
+
if (options.skip)
|
|
228
|
+
return options.initialTools;
|
|
125
229
|
const request = options.request.trim();
|
|
126
230
|
const apiKey = options.personalApiKey?.trim();
|
|
127
231
|
const builderAuth = options.builderAuth;
|
|
@@ -151,48 +255,71 @@ export async function preloadJevTools(options) {
|
|
|
151
255
|
if (candidates.length === 0)
|
|
152
256
|
return options.initialTools;
|
|
153
257
|
const prefetchLimit = Math.max(1, Math.min(options.limit ?? DEFAULT_PREFETCH_LIMIT, MAX_PREFETCH_LIMIT));
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
258
|
+
const remaining = Math.min(JEV_TIMEOUT_MS, options.deadlineAt === undefined
|
|
259
|
+
? JEV_TIMEOUT_MS
|
|
260
|
+
: options.deadlineAt - Date.now());
|
|
261
|
+
if (remaining <= 0)
|
|
262
|
+
return options.initialTools;
|
|
263
|
+
const controller = new AbortController();
|
|
264
|
+
let timeout;
|
|
265
|
+
const selectedNames = await Promise.race([
|
|
266
|
+
rankJevCandidates({
|
|
267
|
+
request,
|
|
268
|
+
apiKey,
|
|
269
|
+
personalApiKey: options.personalApiKey,
|
|
270
|
+
candidates: candidates.map((candidate) => ({
|
|
271
|
+
id: candidate.name,
|
|
272
|
+
description: candidate.description,
|
|
273
|
+
metadata: { kind: "tool" },
|
|
274
|
+
})),
|
|
275
|
+
candidateStateKey: "candidate_tools",
|
|
276
|
+
answerKey: "best_tool",
|
|
277
|
+
builderAuth,
|
|
278
|
+
question: "Which tools should be loaded into the agent context first for this task? Pick the most useful tool; probabilities may be used to keep a small ranked shortlist.",
|
|
279
|
+
limit: prefetchLimit,
|
|
280
|
+
signal: controller.signal,
|
|
281
|
+
timeoutMs: remaining,
|
|
282
|
+
}),
|
|
283
|
+
new Promise((resolve) => {
|
|
284
|
+
timeout = setTimeout(() => {
|
|
285
|
+
controller.abort();
|
|
286
|
+
resolve([]);
|
|
287
|
+
}, remaining);
|
|
288
|
+
}),
|
|
289
|
+
]);
|
|
290
|
+
if (timeout)
|
|
291
|
+
clearTimeout(timeout);
|
|
169
292
|
return selectedNames.length > 0
|
|
170
293
|
? prependSelectedTools(options, selectedNames)
|
|
171
294
|
: options.initialTools;
|
|
172
295
|
}
|
|
173
296
|
async function requestJev(options) {
|
|
297
|
+
options.signal?.throwIfAborted();
|
|
174
298
|
const personalApiKey = options.personalApiKey?.trim();
|
|
175
299
|
if (options.builderAuth) {
|
|
176
300
|
try {
|
|
177
|
-
return await requestJevThroughBuilder(options.builderAuth, options.request);
|
|
301
|
+
return await requestJevThroughBuilder(options.builderAuth, options.request, { signal: options.signal, timeoutMs: options.timeoutMs });
|
|
178
302
|
}
|
|
179
303
|
catch (error) {
|
|
304
|
+
options.signal?.throwIfAborted();
|
|
180
305
|
if (!personalApiKey)
|
|
181
306
|
throw error;
|
|
182
307
|
console.warn("[agent] Builder Jev proxy unavailable; falling back to the direct Jev API.", error instanceof Error ? error.message : "unknown error");
|
|
183
|
-
return requestJevDirect(personalApiKey, options.request);
|
|
308
|
+
return requestJevDirect(personalApiKey, options.request, options);
|
|
184
309
|
}
|
|
185
310
|
}
|
|
186
311
|
if (!personalApiKey) {
|
|
187
312
|
throw new Error("Builder Jev proxy is unavailable.");
|
|
188
313
|
}
|
|
189
|
-
return requestJevDirect(personalApiKey, options.request);
|
|
314
|
+
return requestJevDirect(personalApiKey, options.request, options);
|
|
190
315
|
}
|
|
191
|
-
async function requestJevDirect(apiKey, request) {
|
|
316
|
+
async function requestJevDirect(apiKey, request, options) {
|
|
317
|
+
options.signal?.throwIfAborted();
|
|
192
318
|
const { choice, TypeSafeClient } = await import("@typesafe-ai/sdk");
|
|
319
|
+
options.signal?.throwIfAborted();
|
|
193
320
|
const client = new TypeSafeClient({
|
|
194
321
|
apiKey,
|
|
195
|
-
timeout: JEV_TIMEOUT_MS,
|
|
322
|
+
timeout: Math.max(1, Math.min(JEV_TIMEOUT_MS, options.timeoutMs ?? JEV_TIMEOUT_MS)),
|
|
196
323
|
retry: { maxRetries: 0 },
|
|
197
324
|
});
|
|
198
325
|
const systemOne = client.systemOne.bind(client);
|
|
@@ -201,7 +328,7 @@ async function requestJevDirect(apiKey, request) {
|
|
|
201
328
|
questions: {
|
|
202
329
|
[Object.keys(request.questions)[0]]: choice(Object.values(request.questions)[0].instructions, Object.values(request.questions)[0].criteria),
|
|
203
330
|
},
|
|
204
|
-
}));
|
|
331
|
+
}, options.signal ? { signal: options.signal } : undefined));
|
|
205
332
|
}
|
|
206
333
|
export async function requestJevThroughBuilder(auth, request, options = {}) {
|
|
207
334
|
const controller = new AbortController();
|
|
@@ -4,6 +4,7 @@ import type { Task } from "../a2a/types.js";
|
|
|
4
4
|
import { type ActionAutomationContext, type ActionCaller } from "../action.js";
|
|
5
5
|
import { type ArtifactReceipt } from "../artifacts/detect.js";
|
|
6
6
|
import type { AgentNativeHarnessSetting } from "../config.js";
|
|
7
|
+
import { type JevPromptContextCandidate } from "../server/agent-chat/prompt-resources.js";
|
|
7
8
|
import { type BuilderGatewayAuth } from "../server/credential-provider.js";
|
|
8
9
|
import { fireInternalDispatch } from "../server/self-dispatch.js";
|
|
9
10
|
import { type ReasoningEffort } from "../shared/reasoning-effort.js";
|
|
@@ -407,16 +408,26 @@ export interface ProductionAgentOptions {
|
|
|
407
408
|
attachments: AgentChatAttachment[];
|
|
408
409
|
references: AgentChatReference[];
|
|
409
410
|
threadId?: string;
|
|
411
|
+
/** Recent visible conversation text, bounded and with tool outputs omitted. */
|
|
412
|
+
requestContext: string;
|
|
413
|
+
/** Shared deadline for optional prompt-context preloading. */
|
|
414
|
+
contextPrefetchDeadlineAt: number;
|
|
410
415
|
internalContinuation?: boolean;
|
|
416
|
+
dispatchToBackground: boolean;
|
|
417
|
+
isBackgroundWorker?: boolean;
|
|
411
418
|
mode: AgentExecutionMode;
|
|
412
419
|
}) => void | {
|
|
413
420
|
message?: string;
|
|
414
421
|
displayMessage?: string;
|
|
415
422
|
attachments?: AgentChatAttachment[];
|
|
423
|
+
jevPromptCandidates?: JevPromptContextCandidate[];
|
|
424
|
+
jevFallbackCandidateIds?: string[];
|
|
416
425
|
} | Promise<void | {
|
|
417
426
|
message?: string;
|
|
418
427
|
displayMessage?: string;
|
|
419
428
|
attachments?: AgentChatAttachment[];
|
|
429
|
+
jevPromptCandidates?: JevPromptContextCandidate[];
|
|
430
|
+
jevFallbackCandidateIds?: string[];
|
|
420
431
|
}>;
|
|
421
432
|
/**
|
|
422
433
|
* Resolve the exact action registry exposed to one interactive agent-chat
|
|
@@ -47,7 +47,7 @@ import { loadPriorTurnToolCallJournal } from "./engine/tool-call-journal-seed.js
|
|
|
47
47
|
import { backfillEngineMessagesToolResults, stringifyToolUseInputForGateway, unmatchedToolResultReplayText, } from "./engine/translate-anthropic.js";
|
|
48
48
|
import { EngineError } from "./engine/types.js";
|
|
49
49
|
import { filterHostedHarnessToolNames, normalizeHostedHarnessRuntime, } from "./harness/hosted.js";
|
|
50
|
-
import { preloadJevTools } from "./jev-tool-prefetch.js";
|
|
50
|
+
import { buildRecentUserRequestContext, buildJevRequestContext, preloadJevTools, } from "./jev-tool-prefetch.js";
|
|
51
51
|
import { getDefaultMaxIterations, getDefaultMaxRunInputTokens, MAX_AGENT_MAX_ITERATIONS, MIN_AGENT_MAX_ITERATIONS, normalizeMaxIterations, normalizeMaxRunInputTokens, readAgentLoopSettings, } from "./loop-settings.js";
|
|
52
52
|
import { getContextWindowForModel, resolveFallbackModel, } from "./model-config.js";
|
|
53
53
|
import { maybeCompactThread, buildObservationalContext, hasObservationalMemory, serializeObservationalMemoryBlock, } from "./observational-memory/index.js";
|
|
@@ -7483,10 +7483,8 @@ export function createProductionAgentHandler(options) {
|
|
|
7483
7483
|
if (requestRunCtx) {
|
|
7484
7484
|
requestRunCtx.browserTabId = requestBrowserTabId;
|
|
7485
7485
|
requestRunCtx.chatScope = requestChatScope;
|
|
7486
|
-
// Let
|
|
7487
|
-
//
|
|
7488
|
-
// analytics data-dictionary read) that otherwise stalls the worker before
|
|
7489
|
-
// it claims its run. Set early — before the system-prompt build runs.
|
|
7486
|
+
// Let app prompt hooks select bounded worker-safe enrichment. Set this
|
|
7487
|
+
// before request preparation and system-prompt assembly.
|
|
7490
7488
|
requestRunCtx.isBackgroundWorker = isBackgroundWorker;
|
|
7491
7489
|
}
|
|
7492
7490
|
const requestMode = body.mode === "plan" ? "plan" : "act";
|
|
@@ -7499,10 +7497,16 @@ export function createProductionAgentHandler(options) {
|
|
|
7499
7497
|
let requestMessage = hasMessageText ? message : "Use the attached context.";
|
|
7500
7498
|
let requestAttachments = Array.isArray(attachments) ? attachments : [];
|
|
7501
7499
|
let requestDisplayMessage = displayMessage;
|
|
7500
|
+
const requestContext = buildRecentUserRequestContext({
|
|
7501
|
+
request: requestMessage,
|
|
7502
|
+
history,
|
|
7503
|
+
structuredHistory,
|
|
7504
|
+
});
|
|
7502
7505
|
// Resolve owner first so we can look up a per-owner API key. Users
|
|
7503
7506
|
// who bring their own key use their key for this request (durable
|
|
7504
7507
|
// across serverless cold starts via the settings table).
|
|
7505
7508
|
const ownerEmail = await resolveAgentOwnerEmail(options, event);
|
|
7509
|
+
const contextPrefetchDeadlineAt = Date.now() + 1_300;
|
|
7506
7510
|
const preparedRequest = await options.prepareRequest?.({
|
|
7507
7511
|
event,
|
|
7508
7512
|
ownerEmail,
|
|
@@ -7511,9 +7515,15 @@ export function createProductionAgentHandler(options) {
|
|
|
7511
7515
|
attachments: requestAttachments,
|
|
7512
7516
|
references,
|
|
7513
7517
|
threadId,
|
|
7518
|
+
requestContext,
|
|
7519
|
+
contextPrefetchDeadlineAt,
|
|
7514
7520
|
internalContinuation: Boolean(internalContinuation),
|
|
7521
|
+
dispatchToBackground,
|
|
7522
|
+
isBackgroundWorker,
|
|
7515
7523
|
mode: requestMode,
|
|
7516
7524
|
});
|
|
7525
|
+
let jevPromptCandidates = [];
|
|
7526
|
+
let jevFallbackCandidateIds = [];
|
|
7517
7527
|
if (preparedRequest) {
|
|
7518
7528
|
if (typeof preparedRequest.message === "string" &&
|
|
7519
7529
|
preparedRequest.message.trim().length > 0) {
|
|
@@ -7525,7 +7535,18 @@ export function createProductionAgentHandler(options) {
|
|
|
7525
7535
|
if (Array.isArray(preparedRequest.attachments)) {
|
|
7526
7536
|
requestAttachments = preparedRequest.attachments;
|
|
7527
7537
|
}
|
|
7538
|
+
if (Array.isArray(preparedRequest.jevPromptCandidates)) {
|
|
7539
|
+
jevPromptCandidates = preparedRequest.jevPromptCandidates;
|
|
7540
|
+
}
|
|
7541
|
+
if (Array.isArray(preparedRequest.jevFallbackCandidateIds)) {
|
|
7542
|
+
jevFallbackCandidateIds = preparedRequest.jevFallbackCandidateIds;
|
|
7543
|
+
}
|
|
7528
7544
|
}
|
|
7545
|
+
const jevRequestContext = buildJevRequestContext({
|
|
7546
|
+
request: requestMessage,
|
|
7547
|
+
history,
|
|
7548
|
+
structuredHistory,
|
|
7549
|
+
});
|
|
7529
7550
|
const requestedHostedHarness = normalizeHostedHarnessRuntime(requestHarness?.runtime);
|
|
7530
7551
|
if (requestHarness !== undefined && !requestedHostedHarness) {
|
|
7531
7552
|
setResponseStatus(event, 400);
|
|
@@ -8146,7 +8167,9 @@ export function createProductionAgentHandler(options) {
|
|
|
8146
8167
|
: undefined;
|
|
8147
8168
|
const [requestTools, jevContext] = await Promise.all([
|
|
8148
8169
|
preloadJevTools({
|
|
8149
|
-
request:
|
|
8170
|
+
request: jevRequestContext,
|
|
8171
|
+
skip: Boolean(internalContinuation || dispatchToBackground),
|
|
8172
|
+
deadlineAt: contextPrefetchDeadlineAt,
|
|
8150
8173
|
apiKey: jevContextCredentials.apiKey,
|
|
8151
8174
|
personalApiKey: jevContextCredentials.personalApiKey,
|
|
8152
8175
|
builderAuth: jevContextCredentials.builderAuth,
|
|
@@ -8156,12 +8179,20 @@ export function createProductionAgentHandler(options) {
|
|
|
8156
8179
|
readOnlyOnly: requestMode === "plan",
|
|
8157
8180
|
}),
|
|
8158
8181
|
preloadJevContextForPrompt({
|
|
8159
|
-
request:
|
|
8182
|
+
request: jevRequestContext,
|
|
8183
|
+
appId: options.appId,
|
|
8184
|
+
owner: ownerEmail ?? undefined,
|
|
8185
|
+
orgId: getRequestOrgId() ?? null,
|
|
8160
8186
|
apiKey: jevContextCredentials.apiKey,
|
|
8161
8187
|
personalApiKey: jevContextCredentials.personalApiKey,
|
|
8162
8188
|
builderAuth: jevContextCredentials.builderAuth,
|
|
8163
8189
|
compact: options.jevContextCompact,
|
|
8164
8190
|
maxChars: jevContextMaxChars,
|
|
8191
|
+
contextPrefetchDeadlineAt,
|
|
8192
|
+
dispatchToBackground,
|
|
8193
|
+
internalContinuation: Boolean(internalContinuation),
|
|
8194
|
+
candidates: jevPromptCandidates,
|
|
8195
|
+
fallbackCandidateIds: jevFallbackCandidateIds,
|
|
8165
8196
|
}),
|
|
8166
8197
|
]);
|
|
8167
8198
|
if (jevContext)
|
|
@@ -8174,7 +8205,7 @@ export function createProductionAgentHandler(options) {
|
|
|
8174
8205
|
...(jevContext
|
|
8175
8206
|
? await buildSystemManifestSections([
|
|
8176
8207
|
{
|
|
8177
|
-
label: "Jev-prefetched
|
|
8208
|
+
label: "Jev-prefetched context",
|
|
8178
8209
|
provenance: "runtime-context",
|
|
8179
8210
|
governance: "inherited",
|
|
8180
8211
|
content: jevContext,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const runtimeConfig: z.ZodObject<{
|
|
3
|
+
backgroundJobsEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
3
4
|
databasePoolMax: z.ZodOptional<z.ZodNumber>;
|
|
4
5
|
agentChatStreaming: z.ZodDefault<z.ZodBoolean>;
|
|
5
6
|
vercelBranchUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export const runtimeConfig = z.object({
|
|
3
|
+
backgroundJobsEnabled: z.boolean().optional().meta({
|
|
4
|
+
env: "RUN_BACKGROUND_JOBS",
|
|
5
|
+
doc: "Run app-owned recurring background jobs. Defaults to enabled only in production.",
|
|
6
|
+
}),
|
|
3
7
|
databasePoolMax: z.number().int().positive().optional().meta({
|
|
4
8
|
env: "AGENT_NATIVE_DB_POOL_MAX",
|
|
5
9
|
doc: "Maximum connections in each framework database pool. Defaults vary by runtime.",
|
|
@@ -128,6 +128,7 @@ export declare const appConfigSchema: z.ZodObject<{
|
|
|
128
128
|
publicUploadFallback: z.ZodDefault<z.ZodBoolean>;
|
|
129
129
|
}, z.core.$strip>>;
|
|
130
130
|
runtime: z.ZodPrefault<z.ZodObject<{
|
|
131
|
+
backgroundJobsEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
131
132
|
databasePoolMax: z.ZodOptional<z.ZodNumber>;
|
|
132
133
|
agentChatStreaming: z.ZodDefault<z.ZodBoolean>;
|
|
133
134
|
vercelBranchUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -61,6 +61,8 @@ export interface AgentSidebarProps {
|
|
|
61
61
|
position?: "left" | "right";
|
|
62
62
|
/** Whether the sidebar starts open. Default: false */
|
|
63
63
|
defaultOpen?: boolean;
|
|
64
|
+
/** Disable the Cmd+I / Ctrl+I shortcut that opens chat. */
|
|
65
|
+
disableChatShortcut?: boolean;
|
|
64
66
|
/** Whether to render the panel's header collapse button. Default: true. */
|
|
65
67
|
showCollapseButton?: boolean;
|
|
66
68
|
/** Animate the mobile overlay in a sheet-style slide transition. Default: true */
|
|
@@ -150,7 +152,7 @@ export interface AgentSidebarProps {
|
|
|
150
152
|
* Wraps app content with a toggleable agent sidebar.
|
|
151
153
|
* Use AgentToggleButton in your header to open/close it.
|
|
152
154
|
*/
|
|
153
|
-
export declare function AgentSidebar({ children, enabled, emptyStateText, defaultMode, suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, onConnectProvider, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position, defaultOpen, showCollapseButton, animateMobile, animateDesktop, chatViewTransition, chatViewTransitionHandoff, storageKey, openStorageKey, restoreActiveThread, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning, onFullscreenRequest, onOpenSettings, onNewCliTab, onNewUiTab, renderCliTab, newTabMode, newCliTabLabel, newUiTabLabel, scope, chatHistory, toggleScopeId, isolateHistoryByScope, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding, thinkingDisplay, showModelSelector, chatOnly, }: AgentSidebarProps): React.JSX.Element;
|
|
155
|
+
export declare function AgentSidebar({ children, enabled, emptyStateText, defaultMode, suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, onConnectProvider, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position, defaultOpen, disableChatShortcut, showCollapseButton, animateMobile, animateDesktop, chatViewTransition, chatViewTransitionHandoff, storageKey, openStorageKey, restoreActiveThread, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning, onFullscreenRequest, onOpenSettings, onNewCliTab, onNewUiTab, renderCliTab, newTabMode, newCliTabLabel, newUiTabLabel, scope, chatHistory, toggleScopeId, isolateHistoryByScope, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding, thinkingDisplay, showModelSelector, chatOnly, }: AgentSidebarProps): React.JSX.Element;
|
|
154
156
|
/**
|
|
155
157
|
* Focus the agent chat composer input.
|
|
156
158
|
* Opens the sidebar if closed, then focuses the text input.
|
|
@@ -161,7 +161,7 @@ function AgentSidebarPanelSkeleton() {
|
|
|
161
161
|
* Wraps app content with a toggleable agent sidebar.
|
|
162
162
|
* Use AgentToggleButton in your header to open/close it.
|
|
163
163
|
*/
|
|
164
|
-
export function AgentSidebar({ children, enabled = true, emptyStateText = "How can I help you?", defaultMode = "chat", suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, onConnectProvider, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position
|
|
164
|
+
export function AgentSidebar({ children, enabled = true, emptyStateText = "How can I help you?", defaultMode = "chat", suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, onConnectProvider, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position, defaultOpen, disableChatShortcut = false, showCollapseButton = true, animateMobile = true, animateDesktop = true, chatViewTransition = false, chatViewTransitionHandoff = false, storageKey, openStorageKey, restoreActiveThread = true, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar = true, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning = false, onFullscreenRequest, onOpenSettings, onNewCliTab, onNewUiTab, renderCliTab, newTabMode = "ui", newCliTabLabel, newUiTabLabel, scope, chatHistory, toggleScopeId, isolateHistoryByScope = false, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding = false, thinkingDisplay, showModelSelector, chatOnly = true, }) {
|
|
165
165
|
const resolvedBrowserTabId = browserTabId ??
|
|
166
166
|
(typeof window === "undefined" ? undefined : getBrowserTabId());
|
|
167
167
|
const staticHostedHarnessEnabled = isHostedHarnessConfigured(injectedAgentNativeConfig().harness);
|
|
@@ -192,8 +192,8 @@ export function AgentSidebar({ children, enabled = true, emptyStateText = "How c
|
|
|
192
192
|
onAgentChange?.(agent);
|
|
193
193
|
}
|
|
194
194
|
: onAgentChange;
|
|
195
|
-
const effectivePosition = hostedHarnessUi ? "left" :
|
|
196
|
-
const effectiveDefaultOpen =
|
|
195
|
+
const effectivePosition = position ?? (hostedHarnessUi ? "left" : "right");
|
|
196
|
+
const effectiveDefaultOpen = defaultOpen ?? hostedHarnessUi;
|
|
197
197
|
const effectiveShowTabBar = hostedHarnessUi || showTabBar;
|
|
198
198
|
const effectiveAnimateDesktop = hostedHarnessUi ? false : animateDesktop;
|
|
199
199
|
const sidebarOpenStorageKey = openStorageKey ?? storageKey;
|
|
@@ -305,10 +305,6 @@ export function AgentSidebar({ children, enabled = true, emptyStateText = "How c
|
|
|
305
305
|
hostedHarnessRuntime,
|
|
306
306
|
hostedHarnessStorageKey,
|
|
307
307
|
]);
|
|
308
|
-
useEffect(() => {
|
|
309
|
-
if (hostedHarnessUi)
|
|
310
|
-
setOpenPersisted(true);
|
|
311
|
-
}, [hostedHarnessUi, setOpenPersisted]);
|
|
312
308
|
const applyUrlOpenOverride = useCallback(() => {
|
|
313
309
|
const override = consumeAgentSidebarUrlOpenOverride(sidebarOpenStorageKey);
|
|
314
310
|
if (override !== null)
|
|
@@ -596,8 +592,8 @@ export function AgentSidebar({ children, enabled = true, emptyStateText = "How c
|
|
|
596
592
|
window.addEventListener("message", handleMessage);
|
|
597
593
|
return () => window.removeEventListener("message", handleMessage);
|
|
598
594
|
}, [setOpenPersisted]);
|
|
599
|
-
// Cmd+\ / Ctrl+\ toggles
|
|
600
|
-
//
|
|
595
|
+
// Cmd+\ / Ctrl+\ toggles globally; Cmd+I / Ctrl+I can focus chat and attach
|
|
596
|
+
// selected page text as one-shot context for the next turn.
|
|
601
597
|
useEffect(() => {
|
|
602
598
|
const handleKeyDown = (e) => {
|
|
603
599
|
if ((e.metaKey || e.ctrlKey) &&
|
|
@@ -608,7 +604,7 @@ export function AgentSidebar({ children, enabled = true, emptyStateText = "How c
|
|
|
608
604
|
window.dispatchEvent(new CustomEvent("agent-panel:toggle", { detail: { focus: true } }));
|
|
609
605
|
return;
|
|
610
606
|
}
|
|
611
|
-
if ((e.metaKey || e.ctrlKey) && e.key === "i") {
|
|
607
|
+
if (!disableChatShortcut && (e.metaKey || e.ctrlKey) && e.key === "i") {
|
|
612
608
|
if (!shouldHandleAgentPanelChatShortcut(e.target))
|
|
613
609
|
return;
|
|
614
610
|
e.preventDefault();
|
|
@@ -638,7 +634,7 @@ export function AgentSidebar({ children, enabled = true, emptyStateText = "How c
|
|
|
638
634
|
};
|
|
639
635
|
document.addEventListener("keydown", handleKeyDown);
|
|
640
636
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
641
|
-
}, []);
|
|
637
|
+
}, [disableChatShortcut]);
|
|
642
638
|
// Hide sidebar during presentation mode
|
|
643
639
|
useEffect(() => {
|
|
644
640
|
const handler = (event) => {
|
|
@@ -847,7 +843,7 @@ export function AgentSidebar({ children, enabled = true, emptyStateText = "How c
|
|
|
847
843
|
!isPerAppChatHosted &&
|
|
848
844
|
!presentationMode &&
|
|
849
845
|
enabled &&
|
|
850
|
-
(mobileAnimationEnabled ? shouldRenderPanel : open) && (_jsx("div", { className: cn("agent-sidebar-backdrop fixed inset-0 bg-foreground/40", mobileAnimationEnabled && !panelOpen && "pointer-events-none"), "data-agent-sidebar-animation": mobileAnimationEnabled ? "mobile" : undefined, "data-agent-sidebar-state": panelOpen ? "open" : "closed", style: { zIndex: SIDEBAR_OVERLAY_Z_INDEX - 1 }, onClick: () => setOpenPersisted(false) })), shouldMountPanel ? (_jsx(URLSync, { browserTabId: resolvedBrowserTabId })) : null, isResizing ? (_jsx("div", { "aria-hidden": "true", className: "agent-sidebar-resize-overlay" })) : null, isLeft && !presentationMode ? sidebar : null, isLeft && !presentationMode ? drawerPlaceholder : null, _jsx("div", { className: "agent-sidebar-main-surface flex flex-1 flex-col overflow-auto min-w-0", "data-agent-sidebar-main-position":
|
|
846
|
+
(mobileAnimationEnabled ? shouldRenderPanel : open) && (_jsx("div", { className: cn("agent-sidebar-backdrop fixed inset-0 bg-foreground/40", mobileAnimationEnabled && !panelOpen && "pointer-events-none"), "data-agent-sidebar-animation": mobileAnimationEnabled ? "mobile" : undefined, "data-agent-sidebar-state": panelOpen ? "open" : "closed", style: { zIndex: SIDEBAR_OVERLAY_Z_INDEX - 1 }, onClick: () => setOpenPersisted(false) })), shouldMountPanel ? (_jsx(URLSync, { browserTabId: resolvedBrowserTabId })) : null, isResizing ? (_jsx("div", { "aria-hidden": "true", className: "agent-sidebar-resize-overlay" })) : null, isLeft && !presentationMode ? sidebar : null, isLeft && !presentationMode ? drawerPlaceholder : null, _jsx("div", { className: "agent-sidebar-main-surface flex flex-1 flex-col overflow-auto min-w-0", "data-agent-sidebar-main-position": effectivePosition, "data-agent-sidebar-main-state": !isMobile && !presentationMode && panelOpen ? "open" : "closed", "data-agent-sidebar-resizing": isResizing ? "true" : undefined, children: _jsx(ScreenRefreshBoundary, { children: children }) }), !isLeft && !presentationMode ? drawerPlaceholder : null, !isLeft && !presentationMode ? sidebar : null] })] }));
|
|
851
847
|
}
|
|
852
848
|
/**
|
|
853
849
|
* Focus the agent chat composer input.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AGENT_NATIVE_EXCEPTION_EVENT_NAME, addErrorBreadcrumb, captureClientException, captureError, captureException, captureMessage, clearAnalyticsSessionId, configureTracking, getAnalyticsAnonymousId, getAnalyticsSessionId, getFirstTouchAttribution, getSessionReplayContext, getSessionReplayUrl, isErrorCaptureInstalled, maybeStartSessionReplay, setAnalyticsSessionId, setSentryUser, setTrackingContentCaptureEnabled, setTrackingIdentity, startSessionReplay, stopSessionReplay, trackAgentChatLifecycle, trackEvent, trackLifecycleEvent, trackSessionStatus, type AgentChatLifecycleEvent, type CaptureExceptionContext, type CapturedExceptionEvent, type ClientCaptureContext, type ConfigureTrackingOptions, type ErrorCaptureConfigOptions, type ExceptionBreadcrumb, type ExceptionLevel, type FirstTouchAttribution, type SessionReplayContext, type SessionReplayLinkOptions, type SessionReplayOptions, type SessionReplayStartResult, type SessionReplayUrlMatcher, type TrackingIdentityUser, } from "../analytics.js";
|
|
1
|
+
export { AGENT_NATIVE_EXCEPTION_EVENT_NAME, addErrorBreadcrumb, captureClientException, captureError, captureException, captureMessage, clearAnalyticsSessionId, configureTracking, getAnalyticsAnonymousId, getAnalyticsSessionId, getFirstTouchAttribution, getSessionReplayContext, getSessionReplayUrl, isErrorCaptureInstalled, maybeStartSessionReplay, setAnalyticsSessionId, setSentryUser, setTrackingContentCaptureEnabled, setTrackingIdentity, startSessionReplay, stopSessionReplay, trackAgentChatLifecycle, trackAnonymousEvent, trackEvent, trackLifecycleEvent, trackSessionStatus, type AgentChatLifecycleEvent, type CaptureExceptionContext, type CapturedExceptionEvent, type ClientCaptureContext, type ConfigureTrackingOptions, type ErrorCaptureConfigOptions, type ExceptionBreadcrumb, type ExceptionLevel, type FirstTouchAttribution, type SessionReplayContext, type SessionReplayLinkOptions, type SessionReplayOptions, type SessionReplayStartResult, type SessionReplayUrlMatcher, type TrackingIdentityUser, } from "../analytics.js";
|
|
2
2
|
export { track } from "../track.js";
|