@agent-native/core 0.153.4 → 0.153.5
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/templates/analytics/actions/account-deep-dive.ts +1 -0
- package/corpus/templates/analytics/actions/bigquery-query.ts +1 -0
- package/corpus/templates/analytics/actions/bigquery.ts +1 -0
- package/corpus/templates/analytics/actions/content-calendar-schema.ts +1 -0
- package/corpus/templates/analytics/actions/content-calendar.ts +1 -0
- package/corpus/templates/analytics/actions/gcloud.ts +1 -0
- package/corpus/templates/analytics/actions/get-data-program.ts +1 -0
- package/corpus/templates/analytics/actions/get-error-issue.ts +1 -0
- package/corpus/templates/analytics/actions/get-monitor-stats.ts +1 -0
- package/corpus/templates/analytics/actions/get-monitor.ts +1 -0
- package/corpus/templates/analytics/actions/get-session-replay-events.ts +1 -0
- package/corpus/templates/analytics/actions/get-session-replay-summary.ts +1 -0
- package/corpus/templates/analytics/actions/get-session-replay-timeline.ts +1 -0
- package/corpus/templates/analytics/actions/gong-calls.ts +1 -0
- package/corpus/templates/analytics/actions/gong-native-insights.ts +1 -0
- package/corpus/templates/analytics/actions/grafana.ts +1 -0
- package/corpus/templates/analytics/actions/hubspot-deals.ts +1 -0
- package/corpus/templates/analytics/actions/hubspot-metrics.ts +1 -0
- package/corpus/templates/analytics/actions/hubspot-pipelines.ts +1 -0
- package/corpus/templates/analytics/actions/hubspot-records.ts +1 -0
- package/corpus/templates/analytics/actions/jira-search.ts +1 -0
- package/corpus/templates/analytics/actions/jira.ts +1 -0
- package/corpus/templates/analytics/actions/list-error-issues.ts +1 -0
- package/corpus/templates/analytics/actions/list-monitors.ts +1 -0
- package/corpus/templates/analytics/actions/list-session-recordings.ts +1 -0
- package/corpus/templates/analytics/actions/match-error-issues.ts +1 -0
- package/corpus/templates/analytics/actions/prometheus.ts +1 -0
- package/corpus/templates/analytics/actions/pylon-issues.ts +1 -0
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +1 -0
- package/corpus/templates/analytics/actions/query-dashboard-panel.ts +1 -0
- package/corpus/templates/analytics/actions/query-inbound-forms.ts +1 -0
- package/corpus/templates/analytics/actions/run-monitor-check.ts +1 -0
- package/corpus/templates/analytics/actions/sentry.ts +1 -0
- package/corpus/templates/analytics/actions/seo-blog-pages.ts +1 -0
- package/corpus/templates/analytics/actions/seo-page-keywords.ts +1 -0
- package/corpus/templates/analytics/actions/seo-top-keywords.ts +1 -0
- package/corpus/templates/analytics/actions/slack-messages.ts +1 -0
- package/corpus/templates/analytics/actions/stripe.ts +1 -0
- package/corpus/templates/analytics/actions/test-custom-api-connection.ts +1 -0
- package/corpus/templates/analytics/server/lib/real-data-actions.ts +38 -47
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +40 -34
- package/dist/action.d.ts +13 -0
- package/dist/action.js +3 -0
- package/dist/agent/engine/tool-call-journal-seed.d.ts +27 -10
- package/dist/agent/engine/tool-call-journal-seed.js +46 -32
- package/dist/agent/production-agent.d.ts +33 -0
- package/dist/agent/production-agent.js +172 -57
- package/dist/agent/run-loop-with-resume.d.ts +1 -1
- package/dist/agent/run-loop-with-resume.js +49 -35
- package/dist/client/agent-chat-adapter.js +204 -273
- package/dist/client/sse-event-processor.d.ts +7 -0
- package/dist/client/sse-event-processor.js +21 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +5 -5
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/github-repo-files.js +1 -0
- package/dist/provider-api/actions/provider-api.js +1 -0
- package/dist/provider-api/actions/staged-datasets.js +1 -0
- package/dist/provider-api/corpus-jobs.js +1 -0
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/action-discovery.js +2 -0
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +3 -3
|
@@ -414,6 +414,7 @@ export default defineAction({
|
|
|
414
414
|
http: { method: "GET" },
|
|
415
415
|
readOnly: true,
|
|
416
416
|
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
417
|
+
grounding: true,
|
|
417
418
|
run: async (args) => {
|
|
418
419
|
const trimmedQuery = args.query.trim();
|
|
419
420
|
const gaps: string[] = [];
|
|
@@ -56,6 +56,7 @@ export default defineAction({
|
|
|
56
56
|
.describe("Additional Cloud Monitoring filter expression"),
|
|
57
57
|
}),
|
|
58
58
|
http: { method: "GET" },
|
|
59
|
+
grounding: true,
|
|
59
60
|
run: async (args) => {
|
|
60
61
|
const credentials = await requireActionCredentials(
|
|
61
62
|
["BIGQUERY_PROJECT_ID", "GOOGLE_APPLICATION_CREDENTIALS_JSON"],
|
|
@@ -29,6 +29,7 @@ export default defineAction({
|
|
|
29
29
|
http: { method: "GET" },
|
|
30
30
|
readOnly: true,
|
|
31
31
|
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
32
|
+
grounding: true,
|
|
32
33
|
run: async (args) => {
|
|
33
34
|
return getErrorIssue(resolveScope(), args.id, {
|
|
34
35
|
eventsLimit: args.eventsLimit,
|
|
@@ -22,6 +22,7 @@ export default defineAction({
|
|
|
22
22
|
http: { method: "GET" },
|
|
23
23
|
readOnly: true,
|
|
24
24
|
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
25
|
+
grounding: true,
|
|
25
26
|
run: async (args) => {
|
|
26
27
|
return getSessionReplaySummary(args.recordingId, resolveScope());
|
|
27
28
|
},
|
|
@@ -32,6 +32,7 @@ export default defineAction({
|
|
|
32
32
|
http: { method: "GET" },
|
|
33
33
|
readOnly: true,
|
|
34
34
|
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
35
|
+
grounding: true,
|
|
35
36
|
run: async (args) => {
|
|
36
37
|
return getSessionReplayTimeline(args.recordingId, resolveScope(), {
|
|
37
38
|
eventLimit: args.eventLimit,
|
|
@@ -66,6 +66,7 @@ export default defineAction({
|
|
|
66
66
|
Boolean(operation && allowCreditRequest),
|
|
67
67
|
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
68
68
|
http: false,
|
|
69
|
+
grounding: true,
|
|
69
70
|
run: async ({ operation, allowCreditRequest, arguments: args }) => {
|
|
70
71
|
const tools = gongNativeTools(await listVisibleMcpTools());
|
|
71
72
|
if (!operation) {
|
|
@@ -36,6 +36,7 @@ export default defineAction({
|
|
|
36
36
|
to: z.string().optional().describe("Query end time in epoch ms"),
|
|
37
37
|
}),
|
|
38
38
|
readOnly: true,
|
|
39
|
+
grounding: true,
|
|
39
40
|
run: async (args) => {
|
|
40
41
|
const credentials = await requireActionCredentials(
|
|
41
42
|
["GRAFANA_URL", "GRAFANA_API_TOKEN"],
|
|
@@ -15,6 +15,7 @@ export default defineAction({
|
|
|
15
15
|
"Get computed HubSpot sales metrics: win rate, ACV, pipeline value, etc.",
|
|
16
16
|
schema: z.object({}),
|
|
17
17
|
http: { method: "GET" },
|
|
18
|
+
grounding: true,
|
|
18
19
|
run: async () => {
|
|
19
20
|
const [deals, pipelines] = await Promise.all([
|
|
20
21
|
getAllDeals(),
|
|
@@ -10,6 +10,7 @@ export default defineAction({
|
|
|
10
10
|
description: "Get HubSpot deal pipelines and their stages.",
|
|
11
11
|
schema: z.object({}),
|
|
12
12
|
http: { method: "GET" },
|
|
13
|
+
grounding: true,
|
|
13
14
|
run: async () => {
|
|
14
15
|
const allPipelines = await getDealPipelines();
|
|
15
16
|
const pipelines = getVisiblePipelines(allPipelines);
|
|
@@ -49,6 +49,7 @@ export default defineAction({
|
|
|
49
49
|
}),
|
|
50
50
|
http: { method: "GET" },
|
|
51
51
|
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
52
|
+
grounding: true,
|
|
52
53
|
run: async ({ objectType, query, properties, limit, after }) => {
|
|
53
54
|
const result = await searchHubSpotObjects({
|
|
54
55
|
objectType,
|
|
@@ -25,6 +25,7 @@ export default defineAction({
|
|
|
25
25
|
.describe("Comma-separated field names to include"),
|
|
26
26
|
}),
|
|
27
27
|
http: false,
|
|
28
|
+
grounding: true,
|
|
28
29
|
run: async (args) => {
|
|
29
30
|
const credentials = await requireActionCredentials(
|
|
30
31
|
["JIRA_BASE_URL", "JIRA_USER_EMAIL", "JIRA_API_TOKEN"],
|
|
@@ -66,6 +66,7 @@ export default defineAction({
|
|
|
66
66
|
.describe("Lookback days for mode=analytics"),
|
|
67
67
|
}),
|
|
68
68
|
http: { method: "GET" },
|
|
69
|
+
grounding: true,
|
|
69
70
|
run: async (args) => {
|
|
70
71
|
const credentials = await requireActionCredentials(
|
|
71
72
|
["JIRA_BASE_URL", "JIRA_USER_EMAIL", "JIRA_API_TOKEN"],
|
|
@@ -12,6 +12,7 @@ export default defineAction({
|
|
|
12
12
|
"List the current user's uptime monitors with their latest status, latency, and 24h/7d uptime percentage.",
|
|
13
13
|
schema: z.object({}),
|
|
14
14
|
http: { method: "GET" },
|
|
15
|
+
grounding: true,
|
|
15
16
|
run: async () => {
|
|
16
17
|
const email = getRequestUserEmail();
|
|
17
18
|
if (!email) throw new Error("no authenticated user");
|
|
@@ -27,6 +27,7 @@ export default defineAction({
|
|
|
27
27
|
agentTool: false,
|
|
28
28
|
toolCallable: true,
|
|
29
29
|
http: { method: "POST" },
|
|
30
|
+
grounding: true,
|
|
30
31
|
run: async ({ account, accounts, query, days, pageSize, maxPages }) => {
|
|
31
32
|
if (accounts) {
|
|
32
33
|
const response = (await executeProviderApiRequest({
|
|
@@ -69,6 +69,7 @@ export default defineAction({
|
|
|
69
69
|
// natural-language question and Analytics forms the query.
|
|
70
70
|
http: false,
|
|
71
71
|
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
72
|
+
grounding: true,
|
|
72
73
|
run: async (args) => {
|
|
73
74
|
const result = await queryFirstPartyAnalytics(args.sql, resolveScope(), {
|
|
74
75
|
cache: true,
|
|
@@ -14,6 +14,7 @@ export default defineAction({
|
|
|
14
14
|
id: z.string().describe("Monitor id to check now."),
|
|
15
15
|
}),
|
|
16
16
|
http: { method: "POST" },
|
|
17
|
+
grounding: true,
|
|
17
18
|
run: async ({ id }) => {
|
|
18
19
|
const email = getRequestUserEmail();
|
|
19
20
|
if (!email) throw new Error("no authenticated user");
|
|
@@ -44,6 +44,7 @@ export default defineAction({
|
|
|
44
44
|
.describe("Sentry stats category for mode=stats; defaults to error"),
|
|
45
45
|
}),
|
|
46
46
|
http: { method: "GET" },
|
|
47
|
+
grounding: true,
|
|
47
48
|
run: async (args) => {
|
|
48
49
|
const credentials = await requireActionCredentials(
|
|
49
50
|
["SENTRY_SERVER_TOKEN", "SENTRY_AUTH_TOKEN"],
|
|
@@ -10,6 +10,7 @@ export default defineAction({
|
|
|
10
10
|
description: "Get SEO metrics for all blog pages.",
|
|
11
11
|
schema: z.object({}),
|
|
12
12
|
http: { method: "GET" },
|
|
13
|
+
grounding: true,
|
|
13
14
|
run: async () => {
|
|
14
15
|
const pages = await getAllBlogPagesSeo();
|
|
15
16
|
return { pages, total: Object.keys(pages).length };
|
|
@@ -15,6 +15,7 @@ export default defineAction({
|
|
|
15
15
|
.describe("Blog page slug (e.g. micro-frontends)"),
|
|
16
16
|
}),
|
|
17
17
|
http: { method: "GET" },
|
|
18
|
+
grounding: true,
|
|
18
19
|
run: async (args) => {
|
|
19
20
|
if (!args.slug) return { error: "slug is required" };
|
|
20
21
|
const keywords = await getRankedKeywordsForPage(args.slug, 20);
|
|
@@ -16,6 +16,7 @@ export default defineAction({
|
|
|
16
16
|
.describe("Max keywords to return (default 500)"),
|
|
17
17
|
}),
|
|
18
18
|
http: { method: "GET" },
|
|
19
|
+
grounding: true,
|
|
19
20
|
run: async (args) => {
|
|
20
21
|
const limit = Math.min(args.limit ?? 500, 1000);
|
|
21
22
|
const keywords = await getAllTopBlogKeywords(limit);
|
|
@@ -13,45 +13,6 @@ const INJECTED_CONTEXT_BLOCKS = [
|
|
|
13
13
|
"response-guard",
|
|
14
14
|
];
|
|
15
15
|
|
|
16
|
-
export const DATA_QUERY_ACTIONS = new Set([
|
|
17
|
-
"account-deep-dive",
|
|
18
|
-
"bigquery",
|
|
19
|
-
"content-calendar",
|
|
20
|
-
"content-calendar-schema",
|
|
21
|
-
// First-party observability reads are grounded data for incident triage,
|
|
22
|
-
// even though they are not provider queries. Keep the final-response guard
|
|
23
|
-
// from replacing valid session/error/replay evidence with the generic
|
|
24
|
-
// "connect a source" fallback.
|
|
25
|
-
"get-error-issue",
|
|
26
|
-
"get-session-replay-events",
|
|
27
|
-
"get-session-replay-summary",
|
|
28
|
-
"get-session-replay-timeline",
|
|
29
|
-
"list-error-issues",
|
|
30
|
-
"list-session-recordings",
|
|
31
|
-
"match-error-issues",
|
|
32
|
-
"gcloud",
|
|
33
|
-
"gong-calls",
|
|
34
|
-
"gong-native-insights",
|
|
35
|
-
"grafana",
|
|
36
|
-
"hubspot-deals",
|
|
37
|
-
"hubspot-metrics",
|
|
38
|
-
"hubspot-pipelines",
|
|
39
|
-
"hubspot-records",
|
|
40
|
-
"jira",
|
|
41
|
-
"jira-search",
|
|
42
|
-
"provider-api-request",
|
|
43
|
-
"provider-corpus-job",
|
|
44
|
-
"query-staged-dataset",
|
|
45
|
-
"query-agent-native-analytics",
|
|
46
|
-
"query-inbound-forms",
|
|
47
|
-
"sentry",
|
|
48
|
-
"seo-blog-pages",
|
|
49
|
-
"seo-page-keywords",
|
|
50
|
-
"seo-top-keywords",
|
|
51
|
-
"slack-messages",
|
|
52
|
-
"stripe",
|
|
53
|
-
]);
|
|
54
|
-
|
|
55
16
|
export const CORPUS_SOURCE_ACTIONS = new Set([
|
|
56
17
|
"provider-api-request",
|
|
57
18
|
"provider-corpus-job",
|
|
@@ -127,8 +88,39 @@ function isToolName(name: string, expected: string): boolean {
|
|
|
127
88
|
return normalizeActionToolName(name) === expected;
|
|
128
89
|
}
|
|
129
90
|
|
|
130
|
-
|
|
131
|
-
|
|
91
|
+
let groundingActionNames: ReadonlySet<string> | null = null;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Publish the action names whose definitions declare `grounding: true`.
|
|
95
|
+
*
|
|
96
|
+
* The set is pushed in rather than read from `.generated/actions-registry`
|
|
97
|
+
* because that registry imports every action, and `save-analysis` imports this
|
|
98
|
+
* module — importing it back here would close an evaluation cycle. The
|
|
99
|
+
* agent-chat plugin derives the set once at module load; nothing else may.
|
|
100
|
+
*/
|
|
101
|
+
export function registerGroundingActions(names: Iterable<string>): void {
|
|
102
|
+
const normalized = new Set(
|
|
103
|
+
[...names].map((name) => normalizeActionToolName(name)),
|
|
104
|
+
);
|
|
105
|
+
// An empty set is never a real deployment: it means the installed core build
|
|
106
|
+
// predates `grounding` and dropped it from every definition. Left unchecked,
|
|
107
|
+
// the guard would replace every correct grounded answer with "connect data
|
|
108
|
+
// sources" — the exact silent failure this flag replaced.
|
|
109
|
+
if (normalized.size === 0) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
"no action declares grounding: true; the installed @agent-native/core cannot carry the flag",
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
groundingActionNames = normalized;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isGroundingActionName(name: string): boolean {
|
|
118
|
+
if (!groundingActionNames) {
|
|
119
|
+
throw new Error(
|
|
120
|
+
"grounding actions were never registered: the analytics response guard cannot tell a grounded turn from an ungrounded one",
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
return groundingActionNames.has(normalizeActionToolName(name));
|
|
132
124
|
}
|
|
133
125
|
|
|
134
126
|
function isDashboardConstructionActionName(name: string): boolean {
|
|
@@ -214,7 +206,7 @@ function getRunCodeBridgeToolNames(content: string | undefined): string[] {
|
|
|
214
206
|
|
|
215
207
|
function hasRunCodeDataQueryAttempt(content: string | undefined): boolean {
|
|
216
208
|
return getRunCodeBridgeToolNames(content).some(
|
|
217
|
-
(name) =>
|
|
209
|
+
(name) => isGroundingActionName(name) || isMcpDataSourceTool(name),
|
|
218
210
|
);
|
|
219
211
|
}
|
|
220
212
|
|
|
@@ -530,10 +522,9 @@ export function hasIncompleteDataEvidence(
|
|
|
530
522
|
const name = String(result.name ?? "");
|
|
531
523
|
if (
|
|
532
524
|
name &&
|
|
533
|
-
!
|
|
525
|
+
!isGroundingActionName(name) &&
|
|
534
526
|
!isMcpDataSourceTool(name) &&
|
|
535
|
-
!isToolName(name, "run-code")
|
|
536
|
-
!isToolName(name, "provider-api-request")
|
|
527
|
+
!isToolName(name, "run-code")
|
|
537
528
|
) {
|
|
538
529
|
return false;
|
|
539
530
|
}
|
|
@@ -594,7 +585,7 @@ export function hasDataQueryAttempt(
|
|
|
594
585
|
if (isToolName(name, "run-code")) {
|
|
595
586
|
return hasRunCodeDataQueryAttempt(result.content);
|
|
596
587
|
}
|
|
597
|
-
return
|
|
588
|
+
return isGroundingActionName(name) || isMcpDataSourceTool(name);
|
|
598
589
|
});
|
|
599
590
|
}
|
|
600
591
|
|
|
@@ -605,7 +596,7 @@ function isFailedDataQueryAttempt(result: {
|
|
|
605
596
|
}): boolean {
|
|
606
597
|
const name = String(result.name ?? "");
|
|
607
598
|
const isDataQuery =
|
|
608
|
-
|
|
599
|
+
isGroundingActionName(name) ||
|
|
609
600
|
isMcpDataSourceTool(name) ||
|
|
610
601
|
(isToolName(name, "run-code") &&
|
|
611
602
|
hasRunCodeDataQueryAttempt(result.content));
|
|
@@ -29,8 +29,28 @@ import {
|
|
|
29
29
|
looksLikeAnalyticsDataRequest,
|
|
30
30
|
needsCorpusWorkflowForCoverageSensitiveRequest,
|
|
31
31
|
needsSourceRecordBodyWorkflowForCoverageSensitiveRequest,
|
|
32
|
+
registerGroundingActions,
|
|
32
33
|
} from "../lib/real-data-actions";
|
|
33
34
|
|
|
35
|
+
// Which actions return real data-source evidence is a fact each action states
|
|
36
|
+
// on itself (`grounding: true`). Reading it off the definitions here is what
|
|
37
|
+
// keeps the response guard from drifting behind a newly shipped source action.
|
|
38
|
+
registerGroundingActions(
|
|
39
|
+
Object.entries(actionsRegistry)
|
|
40
|
+
.filter(([, module]) => {
|
|
41
|
+
// Action modules reach the registry either as the module namespace or as
|
|
42
|
+
// an already-unwrapped definition, the same two shapes
|
|
43
|
+
// `loadActionsFromStaticRegistry` normalizes.
|
|
44
|
+
const candidate = module as
|
|
45
|
+
| { grounding?: boolean; default?: { grounding?: boolean } }
|
|
46
|
+
| undefined;
|
|
47
|
+
return (
|
|
48
|
+
candidate?.grounding === true || candidate?.default?.grounding === true
|
|
49
|
+
);
|
|
50
|
+
})
|
|
51
|
+
.map(([name]) => name),
|
|
52
|
+
);
|
|
53
|
+
|
|
34
54
|
const ANALYTICS_BACKGROUND_RUN_SOFT_TIMEOUT_MS = 13 * 60_000;
|
|
35
55
|
// A background job may legitimately spend minutes inside a provider/tool call,
|
|
36
56
|
// which the shared watchdog already excludes. Outside a tool call, however,
|
|
@@ -764,17 +784,23 @@ export function realDataFinalGuard(
|
|
|
764
784
|
}
|
|
765
785
|
|
|
766
786
|
if (dataQueryAttempted) return null;
|
|
787
|
+
const failedQueryMessage = failedDataQueryAttemptMessage(context.toolResults);
|
|
788
|
+
// Whether the built-in source is worth trying is decided by tool evidence,
|
|
789
|
+
// not by how the draft is worded, so it is asked once for every draft shape.
|
|
790
|
+
// A source that already failed this turn is not an untried source: steering
|
|
791
|
+
// the model back into it is how a permanently failing precondition turns
|
|
792
|
+
// into a retry loop.
|
|
793
|
+
if (firstPartySourceShouldBeTried && !failedQueryMessage) {
|
|
794
|
+
return {
|
|
795
|
+
retryMessage:
|
|
796
|
+
"The user asked for live analytics, and the built-in first-party Analytics source is available even though no external provider is connected. Call `query-agent-native-analytics` for first-party product, usage, conversion, or observability data and answer from that result. If the request specifically names an external provider, explain what is missing and include the real Connect data sources link.",
|
|
797
|
+
fallbackMessage:
|
|
798
|
+
"I couldn't complete a grounded first-party Analytics query yet. Please retry and I'll use the built-in Analytics source before asking you to connect an external provider.",
|
|
799
|
+
maxRetries: 2,
|
|
800
|
+
expandToolSurface: true,
|
|
801
|
+
};
|
|
802
|
+
}
|
|
767
803
|
if (isSafeNoDataAnalyticsResponse(context.text)) {
|
|
768
|
-
if (firstPartySourceShouldBeTried) {
|
|
769
|
-
return {
|
|
770
|
-
retryMessage:
|
|
771
|
-
"The built-in first-party Analytics source is available even though no external provider is connected. Use `query-agent-native-analytics` for the user's first-party product, usage, conversion, or observability question before explaining that data is unavailable. Only guide the user to connect a source if the request specifically needs an external provider.",
|
|
772
|
-
fallbackMessage:
|
|
773
|
-
"I couldn't complete a grounded first-party Analytics query yet. Please retry and I'll use the built-in Analytics source before asking you to connect an external provider.",
|
|
774
|
-
maxRetries: 2,
|
|
775
|
-
expandToolSurface: true,
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
804
|
if (
|
|
779
805
|
needsDataSourceLink &&
|
|
780
806
|
!includesDataSourcesLink(context.text, setupLink)
|
|
@@ -787,7 +813,6 @@ export function realDataFinalGuard(
|
|
|
787
813
|
}
|
|
788
814
|
return null;
|
|
789
815
|
}
|
|
790
|
-
const failedQueryMessage = failedDataQueryAttemptMessage(context.toolResults);
|
|
791
816
|
if (failedQueryMessage) {
|
|
792
817
|
if (
|
|
793
818
|
needsDataSourceLink &&
|
|
@@ -805,11 +830,10 @@ export function realDataFinalGuard(
|
|
|
805
830
|
};
|
|
806
831
|
}
|
|
807
832
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
) {
|
|
833
|
+
// `needsDataSourceLink` already carries "status was checked, the user named an
|
|
834
|
+
// external source, and it is missing or nothing is connected". Restating those
|
|
835
|
+
// clauses here is what made the next branch look reachable.
|
|
836
|
+
if (needsDataSourceLink) {
|
|
813
837
|
return {
|
|
814
838
|
retryMessage: `The requested external source is not connected. Explain what is missing in the context of the user's question and include this exact markdown link: ${setupMarkdown}. Do not use the generic no-grounded-data fallback.`,
|
|
815
839
|
fallbackMessage: `I can help with that once the relevant source is connected. ${setupMarkdown}`,
|
|
@@ -819,24 +843,6 @@ export function realDataFinalGuard(
|
|
|
819
843
|
}
|
|
820
844
|
|
|
821
845
|
const configuredSources = configuredDataSourceLabels(context.toolResults);
|
|
822
|
-
if (firstPartySourceShouldBeTried) {
|
|
823
|
-
return {
|
|
824
|
-
retryMessage:
|
|
825
|
-
"The user asked for live analytics, and the built-in first-party Analytics source is available even though no external provider is connected. Call `query-agent-native-analytics` for first-party product, usage, conversion, or observability data and answer from that result. If the request specifically names an external provider, explain what is missing and include the real Connect data sources link.",
|
|
826
|
-
fallbackMessage:
|
|
827
|
-
"I couldn't complete a grounded first-party Analytics query yet. Please retry and I'll use the built-in Analytics source before asking you to connect an external provider.",
|
|
828
|
-
maxRetries: 2,
|
|
829
|
-
expandToolSurface: true,
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
if (noConnectedExternalSources) {
|
|
833
|
-
return {
|
|
834
|
-
retryMessage: `The user asked for live analytics, but data-source-status found no connected external providers. The built-in first-party source is still available for first-party Analytics data. If this request needs an external source, respond naturally in the context of the user's question, explain what is missing, and include ${setupMarkdown}. Do not use a generic canned no-data response.`,
|
|
835
|
-
fallbackMessage: `I can help with that once the relevant source is connected. ${setupMarkdown}`,
|
|
836
|
-
maxRetries: 2,
|
|
837
|
-
expandToolSurface: true,
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
846
|
const configuredSourceGuidance = configuredSources.length
|
|
841
847
|
? ` \`data-source-status\` already confirmed these connected sources: ${configuredSources.join(", ")}. Do not claim that no sources are connected and do not ask the user to reconnect them. Immediately call the relevant query action for one of those sources.`
|
|
842
848
|
: "";
|
package/dist/action.d.ts
CHANGED
|
@@ -398,6 +398,15 @@ interface DefineActionWithSchema<TSchema extends StandardSchemaV1, TReturn = any
|
|
|
398
398
|
* Only set this manually when you need to override the inference — e.g. a
|
|
399
399
|
* POST action that only reads data but can't use GET for a protocol reason. */
|
|
400
400
|
readOnly?: boolean;
|
|
401
|
+
/** Declares that a successful call returns real evidence retrieved from a data
|
|
402
|
+
* source at call time — a provider API, a warehouse, a connected repo, or the
|
|
403
|
+
* app's own event/observability store. Apps that police fabricated answers
|
|
404
|
+
* (see the Analytics final-response guard) read this instead of keeping a
|
|
405
|
+
* hand-maintained list of action names, which drifts the moment a new source
|
|
406
|
+
* action ships. Orthogonal to `readOnly`: a write that probes a live endpoint
|
|
407
|
+
* and returns the outcome is still grounding. Metadata-only reads (schema,
|
|
408
|
+
* catalogs, saved config) are not. */
|
|
409
|
+
grounding?: boolean;
|
|
401
410
|
/** Set false for read-only tools that should stay available in Act mode but
|
|
402
411
|
* must not run during Plan mode because they perform substantive work
|
|
403
412
|
* rather than lightweight inspection. Defaults to allowed when read-only. */
|
|
@@ -538,6 +547,9 @@ interface DefineActionWithParams<TParams extends Record<string, ParameterSchema>
|
|
|
538
547
|
/** If true, the framework will NOT emit a screen-refresh change event after a
|
|
539
548
|
* successful call. Auto-inferred as `true` when `http.method === "GET"`. */
|
|
540
549
|
readOnly?: boolean;
|
|
550
|
+
/** Declares that a successful call returns real evidence retrieved from a data
|
|
551
|
+
* source at call time. See the schema overload above. */
|
|
552
|
+
grounding?: boolean;
|
|
541
553
|
/** Set false for read-only tools that should stay available in Act mode but
|
|
542
554
|
* must not run during Plan mode. See the schema overload above. */
|
|
543
555
|
allowInPlanMode?: boolean;
|
|
@@ -602,6 +614,7 @@ export interface ActionDefinition<TInput, TReturn> {
|
|
|
602
614
|
readonly maxBodyBytes?: number;
|
|
603
615
|
readonly agentTool?: boolean;
|
|
604
616
|
readonly readOnly?: boolean;
|
|
617
|
+
readonly grounding?: boolean;
|
|
605
618
|
readonly allowInPlanMode?: boolean;
|
|
606
619
|
readonly planMode?: ActionPlanModeConfig<TInput>;
|
|
607
620
|
readonly parallelSafe?: boolean;
|
package/dist/action.js
CHANGED
|
@@ -164,6 +164,9 @@ export function defineAction(options) {
|
|
|
164
164
|
: {}),
|
|
165
165
|
...(typeof agentTool === "boolean" ? { agentTool } : {}),
|
|
166
166
|
...(typeof readOnly === "boolean" ? { readOnly } : {}),
|
|
167
|
+
...(typeof options.grounding === "boolean"
|
|
168
|
+
? { grounding: options.grounding }
|
|
169
|
+
: {}),
|
|
167
170
|
...(typeof options.allowInPlanMode === "boolean"
|
|
168
171
|
? { allowInPlanMode: options.allowInPlanMode }
|
|
169
172
|
: {}),
|