@agent-native/core 0.145.3 → 0.145.4
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/server/plugins/agent-chat.ts +10 -8
- package/corpus/templates/assets/server/plugins/agent-chat.ts +1 -1
- package/corpus/templates/calendar/server/plugins/agent-chat.ts +1 -1
- package/corpus/templates/clips/desktop/src/lib/media-capture-constraints.ts +22 -1
- package/corpus/templates/mail/server/plugins/agent-chat.ts +1 -1
- package/corpus/templates/plan/server/lib/plan-framework-tools.ts +11 -0
- package/corpus/templates/plan/server/plugins/00-mcp.ts +25 -68
- package/corpus/templates/plan/server/plugins/agent-chat.ts +8 -2
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/framework-tools.d.ts +33 -1
- package/dist/framework-tools.js +88 -4
- package/dist/mcp/build-server.d.ts +15 -0
- package/dist/mcp/build-server.js +94 -30
- package/dist/mcp/oauth-client-metadata.js +6 -2
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/provider-api.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/action-discovery.d.ts +3 -18
- package/dist/server/action-discovery.js +9 -65
- package/dist/server/agent-chat/action-filters-a2a.d.ts +14 -2
- package/dist/server/agent-chat/action-filters-a2a.js +1 -1
- package/dist/server/agent-chat/mcp-options.d.ts +106 -0
- package/dist/server/agent-chat/mcp-options.js +50 -0
- package/dist/server/agent-chat/plugin-options.d.ts +17 -26
- package/dist/server/agent-chat-plugin.js +21 -11
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +7 -0
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +1 -1
package/corpus/README.md
CHANGED
|
@@ -907,14 +907,16 @@ export default createAgentChatPlugin({
|
|
|
907
907
|
durableBackgroundRuns: true,
|
|
908
908
|
runSoftTimeoutMs: ANALYTICS_BACKGROUND_RUN_SOFT_TIMEOUT_MS,
|
|
909
909
|
runNoProgressTimeoutMs: ANALYTICS_BACKGROUND_RUN_NO_PROGRESS_TIMEOUT_MS,
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
910
|
+
mcp: {
|
|
911
|
+
connectorCatalog: [...ANALYTICS_CONNECTOR_CATALOG],
|
|
912
|
+
externalAgents: {
|
|
913
|
+
// Keep the direct MCP surface deliberately curated. External agents
|
|
914
|
+
// should use ask_app by default; cataloged actions are optional stable
|
|
915
|
+
// semantic reads for callers with an exact, fully known contract. They
|
|
916
|
+
// are never a fallback for slow or failed delegation.
|
|
917
|
+
authenticatedReads: "off",
|
|
918
|
+
writes: "ask_app_only",
|
|
919
|
+
},
|
|
918
920
|
},
|
|
919
921
|
resolveOrgId: async (event) => {
|
|
920
922
|
const ctx = await getOrgContext(event);
|
|
@@ -90,7 +90,7 @@ export default createAgentChatPlugin({
|
|
|
90
90
|
// background worker, as content, slides and analytics already do.
|
|
91
91
|
durableBackgroundRuns: true,
|
|
92
92
|
initialToolNames: INITIAL_TOOL_NAMES,
|
|
93
|
-
connectorCatalog: [...CALENDAR_CONNECTOR_CATALOG],
|
|
93
|
+
mcp: { connectorCatalog: [...CALENDAR_CONNECTOR_CATALOG] },
|
|
94
94
|
// Enable sandboxed JavaScript execution so Calendar agents can fetch,
|
|
95
95
|
// paginate, and reduce provider data through providerFetch() without us
|
|
96
96
|
// hardcoding one action per Google Calendar / CRM endpoint.
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
chooseFallbackAudioInput,
|
|
3
3
|
enumerateAudioInputDevices,
|
|
4
4
|
isLikelyPhoneMicLabel,
|
|
5
|
+
normalizedMediaDeviceId,
|
|
5
6
|
type AudioInputFallback,
|
|
6
7
|
} from "../../../shared/media-device-selection";
|
|
7
8
|
|
|
@@ -204,7 +205,27 @@ export async function getAudioStreamWithFallback(
|
|
|
204
205
|
const stream = await getVoiceFocusedAudioStream(id);
|
|
205
206
|
return id ? stream : replacePhoneDefaultMicIfPossible(stream);
|
|
206
207
|
} catch (err) {
|
|
207
|
-
|
|
208
|
+
let deviceGone = false;
|
|
209
|
+
if (id && err instanceof DOMException && err.name === "NotAllowedError") {
|
|
210
|
+
try {
|
|
211
|
+
deviceGone = !(await enumerateAudioInputDevices()).some(
|
|
212
|
+
(device) => normalizedMediaDeviceId(device.deviceId) === id,
|
|
213
|
+
);
|
|
214
|
+
} catch (enumerateErr) {
|
|
215
|
+
console.warn(
|
|
216
|
+
"[clips-recorder] could not confirm saved mic is still present after NotAllowedError",
|
|
217
|
+
enumerateErr,
|
|
218
|
+
);
|
|
219
|
+
deviceGone = true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (deviceGone) {
|
|
223
|
+
console.warn(
|
|
224
|
+
"[clips-recorder] saved mic no longer enumerated after NotAllowedError; falling back",
|
|
225
|
+
{ deviceId: id },
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
if (!isMediaConstraintFailure(err) && !deviceGone) throw err;
|
|
208
229
|
if (id) {
|
|
209
230
|
const fallback = await tryFallbackAudioInput(savedLabel, [id]);
|
|
210
231
|
if (fallback) return fallback;
|
|
@@ -40,7 +40,7 @@ export default createAgentChatPlugin({
|
|
|
40
40
|
// background worker, as content, slides and analytics already do.
|
|
41
41
|
durableBackgroundRuns: true,
|
|
42
42
|
initialToolNames: INITIAL_TOOL_NAMES,
|
|
43
|
-
connectorCatalog: [...MAIL_CONNECTOR_CATALOG],
|
|
43
|
+
mcp: { connectorCatalog: [...MAIL_CONNECTOR_CATALOG] },
|
|
44
44
|
resolveOrgId: async (event) => {
|
|
45
45
|
const ctx = await getOrgContext(event);
|
|
46
46
|
return ctx.orgId;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FrameworkToolsConfig } from "@agent-native/core/server";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Framework tool policy shared by Plan's two mounts.
|
|
5
|
+
*
|
|
6
|
+
* Plan serves MCP from a dedicated early plugin (`plugins/00-mcp.ts`) rather
|
|
7
|
+
* than the agent-chat plugin, so the policy has to live somewhere both can
|
|
8
|
+
* read. Setting it in only one place is how an app ends up advertising a tool
|
|
9
|
+
* over MCP that its own agent no longer has.
|
|
10
|
+
*/
|
|
11
|
+
export const PLAN_FRAMEWORK_TOOLS: FrameworkToolsConfig = {};
|
|
@@ -1,77 +1,16 @@
|
|
|
1
1
|
import { mountMCP } from "@agent-native/core/mcp";
|
|
2
2
|
import {
|
|
3
|
+
attachToolSearch,
|
|
4
|
+
filterFrameworkToolGroups,
|
|
3
5
|
loadActionsFromStaticRegistry,
|
|
4
|
-
|
|
6
|
+
resolveFrameworkTools,
|
|
5
7
|
} from "@agent-native/core/server";
|
|
6
8
|
import { getRequestUserEmail } from "@agent-native/core/server/request-context";
|
|
7
9
|
import { createAutomationToolEntries } from "@agent-native/core/triggers";
|
|
8
10
|
|
|
9
11
|
import actionsRegistry from "../../.generated/actions-registry.js";
|
|
10
12
|
import { PLAN_CONNECTOR_CATALOG } from "../lib/plan-connector-catalog.js";
|
|
11
|
-
|
|
12
|
-
const TOOL_SEARCH_ACTION_NAME = "tool-search";
|
|
13
|
-
|
|
14
|
-
function attachPlanToolSearch(
|
|
15
|
-
registry: Record<string, ActionEntry>,
|
|
16
|
-
): Record<string, ActionEntry> {
|
|
17
|
-
const searchableNames = new Set(PLAN_CONNECTOR_CATALOG);
|
|
18
|
-
registry[TOOL_SEARCH_ACTION_NAME] = {
|
|
19
|
-
tool: {
|
|
20
|
-
description:
|
|
21
|
-
"Discover callable Plan MCP tools by name and description. Omit query to list the visible Plan connector surface; pass query to filter by capability.",
|
|
22
|
-
parameters: {
|
|
23
|
-
type: "object",
|
|
24
|
-
properties: {
|
|
25
|
-
query: {
|
|
26
|
-
type: "string",
|
|
27
|
-
description:
|
|
28
|
-
"Optional search text, e.g. create plan, share resource, or comments.",
|
|
29
|
-
},
|
|
30
|
-
limit: {
|
|
31
|
-
type: "number",
|
|
32
|
-
description: "Maximum results to return. Defaults to 8.",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
http: false,
|
|
38
|
-
readOnly: true,
|
|
39
|
-
run: async (args: { query?: unknown; limit?: unknown } = {}) => {
|
|
40
|
-
const query = String(args.query ?? "")
|
|
41
|
-
.trim()
|
|
42
|
-
.toLowerCase();
|
|
43
|
-
const rawLimit = Number(args.limit);
|
|
44
|
-
const limit =
|
|
45
|
-
Number.isFinite(rawLimit) && rawLimit > 0
|
|
46
|
-
? Math.min(Math.floor(rawLimit), 25)
|
|
47
|
-
: 8;
|
|
48
|
-
const results = Object.entries(registry)
|
|
49
|
-
.filter(([name, entry]) => {
|
|
50
|
-
if (name === TOOL_SEARCH_ACTION_NAME) return false;
|
|
51
|
-
if (!searchableNames.has(name)) return false;
|
|
52
|
-
const description = entry.tool.description ?? "";
|
|
53
|
-
if (!query) return true;
|
|
54
|
-
return `${name} ${description}`.toLowerCase().includes(query);
|
|
55
|
-
})
|
|
56
|
-
.slice(0, query ? limit : 100)
|
|
57
|
-
.map(([name, entry]) => ({
|
|
58
|
-
name,
|
|
59
|
-
description: entry.tool.description ?? name,
|
|
60
|
-
readOnly: entry.readOnly === true,
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
query,
|
|
65
|
-
totalTools: Object.keys(registry).filter((name) =>
|
|
66
|
-
searchableNames.has(name),
|
|
67
|
-
).length,
|
|
68
|
-
count: results.length,
|
|
69
|
-
results,
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
return registry;
|
|
74
|
-
}
|
|
13
|
+
import { PLAN_FRAMEWORK_TOOLS } from "../lib/plan-framework-tools.js";
|
|
75
14
|
|
|
76
15
|
function requireMcpOwner(operation: string): string {
|
|
77
16
|
const owner = getRequestUserEmail();
|
|
@@ -84,11 +23,29 @@ function requireMcpOwner(operation: string): string {
|
|
|
84
23
|
}
|
|
85
24
|
|
|
86
25
|
export default function planMcpPlugin(nitroApp: any) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
26
|
+
// This mount deliberately bypasses the agent-chat plugin so the external
|
|
27
|
+
// connector does not wait on chat initialization — which means it has to
|
|
28
|
+
// apply the framework tool policy itself. Reading the same
|
|
29
|
+
// `PLAN_FRAMEWORK_TOOLS` the chat plugin does is what keeps the two mounts
|
|
30
|
+
// from disagreeing about which tools exist.
|
|
31
|
+
const frameworkTools = resolveFrameworkTools({
|
|
32
|
+
frameworkTools: PLAN_FRAMEWORK_TOOLS,
|
|
90
33
|
});
|
|
91
34
|
|
|
35
|
+
const actions = attachToolSearch(
|
|
36
|
+
filterFrameworkToolGroups(
|
|
37
|
+
{
|
|
38
|
+
...loadActionsFromStaticRegistry(actionsRegistry),
|
|
39
|
+
...(frameworkTools.isEnabled("automation")
|
|
40
|
+
? createAutomationToolEntries(() =>
|
|
41
|
+
requireMcpOwner("manage automations"),
|
|
42
|
+
)
|
|
43
|
+
: {}),
|
|
44
|
+
},
|
|
45
|
+
frameworkTools.disabledGroups,
|
|
46
|
+
),
|
|
47
|
+
);
|
|
48
|
+
|
|
92
49
|
mountMCP(nitroApp, {
|
|
93
50
|
name: "Plan",
|
|
94
51
|
title: "Agent-Native Plan",
|
|
@@ -8,6 +8,7 @@ import { z } from "zod";
|
|
|
8
8
|
|
|
9
9
|
import actionsRegistry from "../../.generated/actions-registry.js";
|
|
10
10
|
import { PLAN_CONNECTOR_CATALOG } from "../lib/plan-connector-catalog.js";
|
|
11
|
+
import { PLAN_FRAMEWORK_TOOLS } from "../lib/plan-framework-tools.js";
|
|
11
12
|
import { resolvePlanAnonymousOwner } from "../lib/public-plans.js";
|
|
12
13
|
|
|
13
14
|
const PLAN_BACKGROUND_RUN_SOFT_TIMEOUT_MS = 13 * 60_000;
|
|
@@ -130,8 +131,13 @@ const planAgentChatOptions = {
|
|
|
130
131
|
initialToolNames: INITIAL_TOOL_NAMES,
|
|
131
132
|
anonymousOwner: resolvePlanAnonymousOwner,
|
|
132
133
|
resolveOrgId: async (event) => (await getOrgContext(event)).orgId,
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
frameworkTools: PLAN_FRAMEWORK_TOOLS,
|
|
135
|
+
mcp: {
|
|
136
|
+
// Plan mounts MCP from a dedicated early plugin (`00-mcp.ts`) so its
|
|
137
|
+
// external connector does not wait on chat plugin initialization.
|
|
138
|
+
enabled: false,
|
|
139
|
+
connectorCatalog: PLAN_CONNECTOR_CATALOG,
|
|
140
|
+
},
|
|
135
141
|
durableBackgroundRuns: true,
|
|
136
142
|
runSoftTimeoutMs: PLAN_BACKGROUND_RUN_SOFT_TIMEOUT_MS,
|
|
137
143
|
};
|
|
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
|
|
|
62
62
|
error: string;
|
|
63
63
|
states?: undefined;
|
|
64
64
|
} | {
|
|
65
|
+
error?: undefined;
|
|
65
66
|
states: {
|
|
66
67
|
clientId: number;
|
|
67
68
|
state: string;
|
|
68
69
|
}[];
|
|
69
|
-
error?: undefined;
|
|
70
70
|
}>>;
|
|
71
71
|
/**
|
|
72
72
|
* GET /_agent-native/collab/:docId/users
|
|
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
|
|
|
77
77
|
error: string;
|
|
78
78
|
users?: undefined;
|
|
79
79
|
} | {
|
|
80
|
+
error?: undefined;
|
|
80
81
|
users: {
|
|
81
82
|
clientId: number;
|
|
82
83
|
lastSeen: number;
|
|
83
84
|
}[];
|
|
84
|
-
error?: undefined;
|
|
85
85
|
}>>;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
|
|
14
14
|
*/
|
|
15
15
|
export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
16
|
-
ok?: undefined;
|
|
17
16
|
error: string;
|
|
17
|
+
ok?: undefined;
|
|
18
18
|
} | {
|
|
19
19
|
error?: undefined;
|
|
20
20
|
ok: boolean;
|
|
@@ -103,18 +103,50 @@ export interface ResolvedFrameworkTools {
|
|
|
103
103
|
* "why can't the agent see db-query" report ends up unexplainable.
|
|
104
104
|
*/
|
|
105
105
|
export declare function resolveFrameworkTools(input: FrameworkToolsInput | undefined): ResolvedFrameworkTools;
|
|
106
|
+
/**
|
|
107
|
+
* Which `frameworkTools` switch owns each framework action kit.
|
|
108
|
+
*
|
|
109
|
+
* This map is the authority. `ActionEntry.frameworkGroup` is an optional
|
|
110
|
+
* pre-resolved copy of the same answer, not a requirement: it is stamped only
|
|
111
|
+
* by `mergeCoreSharingActions`, which runs against the ungated `httpActions`
|
|
112
|
+
* registry, so for a year every app loading core kits through
|
|
113
|
+
* `loadActionsFromStaticRegistry` or its own actions directory carried
|
|
114
|
+
* untagged entries and silently ignored eight of the `frameworkTools`
|
|
115
|
+
* switches. Resolve by name and the switch works no matter how the action was
|
|
116
|
+
* registered.
|
|
117
|
+
*
|
|
118
|
+
* Membership does two jobs: one filter subtracts a whole kit from every agent
|
|
119
|
+
* tool surface at once (the plugin spreads these registries at thirteen
|
|
120
|
+
* composition sites), and it keeps these ~45 schemas out of the DEFAULT
|
|
121
|
+
* first-request tool list. They stay reachable through `tool-search`.
|
|
122
|
+
*
|
|
123
|
+
* Anything absent from this map is always-on and must be listed in
|
|
124
|
+
* `ALWAYS_ON_CORE_ACTIONS` instead. `action-discovery.spec.ts` fails when a new
|
|
125
|
+
* core action appears in neither, so "always-on" stays a decision someone made
|
|
126
|
+
* rather than the default that happens when a map goes un-updated.
|
|
127
|
+
*/
|
|
128
|
+
export declare const CORE_ACTION_GROUPS: Record<string, FrameworkToolGroup>;
|
|
106
129
|
/** Structural view of the one field these helpers read, so tagging utilities
|
|
107
130
|
* stay free of an import cycle with `ActionEntry`. */
|
|
108
131
|
interface FrameworkGrouped {
|
|
109
132
|
frameworkGroup?: FrameworkToolGroup;
|
|
110
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Which group owns an action, by name first and tag second.
|
|
136
|
+
*
|
|
137
|
+
* Name first because the name is present on every registration path, while the
|
|
138
|
+
* tag is stamped on exactly one — an app is not less entitled to its
|
|
139
|
+
* `frameworkTools` switches because it loaded core kits from a generated
|
|
140
|
+
* registry instead of `autoDiscoverActions`.
|
|
141
|
+
*/
|
|
142
|
+
export declare function resolveFrameworkGroup(name: string, entry: FrameworkGrouped | undefined): FrameworkToolGroup | undefined;
|
|
111
143
|
/**
|
|
112
144
|
* Drop every action belonging to a disabled group. Returns the input untouched
|
|
113
145
|
* when nothing is disabled so the default path allocates nothing.
|
|
114
146
|
*/
|
|
115
147
|
export declare function filterFrameworkToolGroups<T extends FrameworkGrouped>(actions: Record<string, T>, disabledGroups: ReadonlySet<FrameworkToolGroup>): Record<string, T>;
|
|
116
148
|
/** True for actions the framework contributes rather than the app's own. */
|
|
117
|
-
export declare function isFrameworkGroupedAction(entry: FrameworkGrouped): boolean;
|
|
149
|
+
export declare function isFrameworkGroupedAction(name: string, entry: FrameworkGrouped | undefined): boolean;
|
|
118
150
|
/**
|
|
119
151
|
* Whether a group is live, for prompt builders that only receive the disabled
|
|
120
152
|
* set. Prompt text and tool schemas must agree: a prompt that names a tool the
|
package/dist/framework-tools.js
CHANGED
|
@@ -88,6 +88,88 @@ export function resolveFrameworkTools(input) {
|
|
|
88
88
|
isEnabled: (group) => !disabledGroups.has(group),
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Which `frameworkTools` switch owns each framework action kit.
|
|
93
|
+
*
|
|
94
|
+
* This map is the authority. `ActionEntry.frameworkGroup` is an optional
|
|
95
|
+
* pre-resolved copy of the same answer, not a requirement: it is stamped only
|
|
96
|
+
* by `mergeCoreSharingActions`, which runs against the ungated `httpActions`
|
|
97
|
+
* registry, so for a year every app loading core kits through
|
|
98
|
+
* `loadActionsFromStaticRegistry` or its own actions directory carried
|
|
99
|
+
* untagged entries and silently ignored eight of the `frameworkTools`
|
|
100
|
+
* switches. Resolve by name and the switch works no matter how the action was
|
|
101
|
+
* registered.
|
|
102
|
+
*
|
|
103
|
+
* Membership does two jobs: one filter subtracts a whole kit from every agent
|
|
104
|
+
* tool surface at once (the plugin spreads these registries at thirteen
|
|
105
|
+
* composition sites), and it keeps these ~45 schemas out of the DEFAULT
|
|
106
|
+
* first-request tool list. They stay reachable through `tool-search`.
|
|
107
|
+
*
|
|
108
|
+
* Anything absent from this map is always-on and must be listed in
|
|
109
|
+
* `ALWAYS_ON_CORE_ACTIONS` instead. `action-discovery.spec.ts` fails when a new
|
|
110
|
+
* core action appears in neither, so "always-on" stays a decision someone made
|
|
111
|
+
* rather than the default that happens when a map goes un-updated.
|
|
112
|
+
*/
|
|
113
|
+
export const CORE_ACTION_GROUPS = {
|
|
114
|
+
"share-resource": "sharing",
|
|
115
|
+
"unshare-resource": "sharing",
|
|
116
|
+
"list-resource-shares": "sharing",
|
|
117
|
+
"set-resource-visibility": "sharing",
|
|
118
|
+
"create-agent-resource-link": "sharing",
|
|
119
|
+
"get-feature-flags": "featureFlags",
|
|
120
|
+
"list-feature-flags": "featureFlags",
|
|
121
|
+
"set-feature-flag": "featureFlags",
|
|
122
|
+
"list-recurring-jobs": "automation",
|
|
123
|
+
"manage-recurring-job": "automation",
|
|
124
|
+
"run-automation-now": "automation",
|
|
125
|
+
"list-automation-runs": "automation",
|
|
126
|
+
"list-automations": "automation",
|
|
127
|
+
"manage-automation": "automation",
|
|
128
|
+
"context-manifest-get": "contextXray",
|
|
129
|
+
"context-preview-get": "contextXray",
|
|
130
|
+
"context-pin": "contextXray",
|
|
131
|
+
"context-evict": "contextXray",
|
|
132
|
+
"context-restore": "contextXray",
|
|
133
|
+
"context-report": "contextXray",
|
|
134
|
+
"get-localization-preference": "localization",
|
|
135
|
+
"set-localization-preference": "localization",
|
|
136
|
+
// Profile, credentials, and appearance share one switch: an app that hides
|
|
137
|
+
// its profile surface from the agent hides password management with it.
|
|
138
|
+
"get-user-profile": "userProfile",
|
|
139
|
+
"update-user-profile": "userProfile",
|
|
140
|
+
"get-auth-methods": "userProfile",
|
|
141
|
+
"set-password": "userProfile",
|
|
142
|
+
"change-password": "userProfile",
|
|
143
|
+
"change-appearance": "userProfile",
|
|
144
|
+
"list-audit-events": "audit",
|
|
145
|
+
"get-audit-event": "audit",
|
|
146
|
+
"export-audit-events": "audit",
|
|
147
|
+
"create-resource-version": "history",
|
|
148
|
+
"list-resource-versions": "history",
|
|
149
|
+
"get-resource-version": "history",
|
|
150
|
+
"restore-resource-version": "history",
|
|
151
|
+
"list-resource-history": "history",
|
|
152
|
+
"list-review-comments": "review",
|
|
153
|
+
"create-review-comment": "review",
|
|
154
|
+
"reply-review-comment": "review",
|
|
155
|
+
"resolve-review-thread": "review",
|
|
156
|
+
"delete-review-comment": "review",
|
|
157
|
+
"consume-review-feedback": "review",
|
|
158
|
+
"get-review-feedback": "review",
|
|
159
|
+
"set-review-status": "review",
|
|
160
|
+
"send-review-thread-to-agent": "review",
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Which group owns an action, by name first and tag second.
|
|
164
|
+
*
|
|
165
|
+
* Name first because the name is present on every registration path, while the
|
|
166
|
+
* tag is stamped on exactly one — an app is not less entitled to its
|
|
167
|
+
* `frameworkTools` switches because it loaded core kits from a generated
|
|
168
|
+
* registry instead of `autoDiscoverActions`.
|
|
169
|
+
*/
|
|
170
|
+
export function resolveFrameworkGroup(name, entry) {
|
|
171
|
+
return entry?.frameworkGroup ?? CORE_ACTION_GROUPS[name];
|
|
172
|
+
}
|
|
91
173
|
/**
|
|
92
174
|
* Drop every action belonging to a disabled group. Returns the input untouched
|
|
93
175
|
* when nothing is disabled so the default path allocates nothing.
|
|
@@ -95,12 +177,14 @@ export function resolveFrameworkTools(input) {
|
|
|
95
177
|
export function filterFrameworkToolGroups(actions, disabledGroups) {
|
|
96
178
|
if (disabledGroups.size === 0)
|
|
97
179
|
return actions;
|
|
98
|
-
return Object.fromEntries(Object.entries(actions).filter(([, entry]) =>
|
|
99
|
-
|
|
180
|
+
return Object.fromEntries(Object.entries(actions).filter(([name, entry]) => {
|
|
181
|
+
const group = resolveFrameworkGroup(name, entry);
|
|
182
|
+
return group === undefined || !disabledGroups.has(group);
|
|
183
|
+
}));
|
|
100
184
|
}
|
|
101
185
|
/** True for actions the framework contributes rather than the app's own. */
|
|
102
|
-
export function isFrameworkGroupedAction(entry) {
|
|
103
|
-
return entry
|
|
186
|
+
export function isFrameworkGroupedAction(name, entry) {
|
|
187
|
+
return resolveFrameworkGroup(name, entry) !== undefined;
|
|
104
188
|
}
|
|
105
189
|
/**
|
|
106
190
|
* Whether a group is live, for prompt builders that only receive the disabled
|
|
@@ -71,6 +71,21 @@ export interface MCPConfig {
|
|
|
71
71
|
* a constrained / locked-down mount.
|
|
72
72
|
*/
|
|
73
73
|
builtinCrossAppTools?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* `"app"` serves exactly the app's own tool registry, flat: every action the
|
|
76
|
+
* in-app agent holds, and nothing the in-app agent does not — no cross-app
|
|
77
|
+
* builtins, no `ask-agent`, no `tool-search`, and no compact/connector
|
|
78
|
+
* trimming. `connectorCatalog`, the compact default, and the
|
|
79
|
+
* `--full-catalog` / `AGENT_NATIVE_MCP_FULL_CATALOG` opt-ins are all inert
|
|
80
|
+
* on this mode; `externalAgents.denyActions` and the OAuth scope filter
|
|
81
|
+
* still apply, because both are explicit removals rather than tiering.
|
|
82
|
+
*
|
|
83
|
+
* The dev-open surface split is deliberately NOT bypassed: an
|
|
84
|
+
* unauthenticated loopback probe still gets `actions`, not
|
|
85
|
+
* `productionActions`. Parity is with the app's agent for a real
|
|
86
|
+
* authenticated caller, not an escalation for anonymous ones.
|
|
87
|
+
*/
|
|
88
|
+
catalogMode?: "app";
|
|
74
89
|
/**
|
|
75
90
|
* Curated allow-list of action names served to **external connector** clients
|
|
76
91
|
* on a hosted multi-tenant deployment.
|
package/dist/mcp/build-server.js
CHANGED
|
@@ -142,6 +142,41 @@ function isActionVisibleForOAuthScope(entry, scopes) {
|
|
|
142
142
|
const required = entry.readOnly === true ? "mcp:read" : "mcp:write";
|
|
143
143
|
return hasMcpOAuthScope(scopes, required);
|
|
144
144
|
}
|
|
145
|
+
/** Mirrors `TOOL_SEARCH_ACTION_NAME`; not imported, because `agent/tool-search.ts`
|
|
146
|
+
* reaches Node-only request context and this module must stay bundleable. */
|
|
147
|
+
const TOOL_SEARCH_TOOL_NAME = "tool-search";
|
|
148
|
+
function withoutToolSearch(actions) {
|
|
149
|
+
if (!(TOOL_SEARCH_TOOL_NAME in actions))
|
|
150
|
+
return actions;
|
|
151
|
+
return Object.fromEntries(Object.entries(actions).filter(([name]) => name !== TOOL_SEARCH_TOOL_NAME));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Re-point `tool-search` at the surface this caller can actually reach.
|
|
155
|
+
*
|
|
156
|
+
* The registry's own entry closes over the app's *whole* action registry, but
|
|
157
|
+
* `tools/call` accepts only the advertised set — so unscoped it answers with
|
|
158
|
+
* names that come straight back as "Unknown tool", and its `callable` field
|
|
159
|
+
* reports plan-mode availability, not that gate. Every template that noticed
|
|
160
|
+
* worked around it by hand-rolling a narrowed copy; scoping it here is what
|
|
161
|
+
* makes the trimmed catalog honest without one.
|
|
162
|
+
*/
|
|
163
|
+
function scopeToolSearchToAdvertised(advertised) {
|
|
164
|
+
const entry = advertised[TOOL_SEARCH_TOOL_NAME];
|
|
165
|
+
if (!entry)
|
|
166
|
+
return advertised;
|
|
167
|
+
return {
|
|
168
|
+
...advertised,
|
|
169
|
+
[TOOL_SEARCH_TOOL_NAME]: {
|
|
170
|
+
...entry,
|
|
171
|
+
// Imported lazily: `agent/tool-search.ts` pulls Node-only request
|
|
172
|
+
// context, and this module has to stay bundleable for serverless.
|
|
173
|
+
run: async (args) => {
|
|
174
|
+
const { searchToolRegistry } = await import("../agent/tool-search.js");
|
|
175
|
+
return searchToolRegistry(advertised, args ?? {});
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
145
180
|
const COMPACT_MCP_APP_CATALOG_BUILTINS = new Set([
|
|
146
181
|
"list_apps",
|
|
147
182
|
"open_app",
|
|
@@ -149,9 +184,10 @@ const COMPACT_MCP_APP_CATALOG_BUILTINS = new Set([
|
|
|
149
184
|
"ask_app_status",
|
|
150
185
|
"create_embed_session",
|
|
151
186
|
// `tool-search` MUST stay in every compact/connector surface: it is how a
|
|
152
|
-
// compacted client discovers
|
|
153
|
-
//
|
|
154
|
-
|
|
187
|
+
// compacted client discovers any action on demand, which is what makes
|
|
188
|
+
// "small catalog by default" non-opaque. Discovery is not permission — a
|
|
189
|
+
// searched name still has to be in the advertised set to be callable.
|
|
190
|
+
TOOL_SEARCH_TOOL_NAME,
|
|
155
191
|
]);
|
|
156
192
|
function isActionAdvertisedInCompactMcpAppCatalog(name, entry, config) {
|
|
157
193
|
if (COMPACT_MCP_APP_CATALOG_BUILTINS.has(name))
|
|
@@ -1115,16 +1151,36 @@ export async function createMCPServerForRequest(config, identity, requestMeta) {
|
|
|
1115
1151
|
const baseActions = useFullSurface && config.productionActions
|
|
1116
1152
|
? config.productionActions
|
|
1117
1153
|
: config.actions;
|
|
1118
|
-
const
|
|
1154
|
+
const appCatalog = config.catalogMode === "app";
|
|
1155
|
+
// The app catalog IS a full flat catalog, so the `--full-catalog` opt-ins
|
|
1156
|
+
// have nothing left to escalate — collapsing them here keeps every tier gate
|
|
1157
|
+
// below reading one flag instead of testing `appCatalog` a fifth time.
|
|
1158
|
+
const fullCatalogRequested = !appCatalog && explicitlyRequestsFullMcpCatalog(requestMeta);
|
|
1159
|
+
// `tool-search` earns its place only on a *trimmed* catalog, where it is how
|
|
1160
|
+
// a client reaches an action that was not listed. On a flat catalog — app
|
|
1161
|
+
// mode or the `--full-catalog` opt-in — every tool is already in `tools/list`
|
|
1162
|
+
// beside it, so it can only ever describe its own neighbours while spending
|
|
1163
|
+
// a tool slot and a round trip to do it.
|
|
1164
|
+
const flatCatalog = appCatalog || fullCatalogRequested;
|
|
1165
|
+
// `catalogMode: "app"` asks for parity with the in-app agent, so the cross-app
|
|
1166
|
+
// builtins the MCP layer adds on its own come back off too.
|
|
1167
|
+
const mergedActions = appCatalog
|
|
1168
|
+
? baseActions
|
|
1169
|
+
: mergeBuiltinTools(config, baseActions, requestMeta);
|
|
1170
|
+
// Strip from `actions`, not just the advertised set: on the full-catalog tier
|
|
1171
|
+
// `actions` IS the callable surface, so filtering only the listing would
|
|
1172
|
+
// leave `tool-search` callable but invisible.
|
|
1173
|
+
const actions = flatCatalog
|
|
1174
|
+
? withoutToolSearch(mergedActions)
|
|
1175
|
+
: mergedActions;
|
|
1119
1176
|
const visibleActions = Object.fromEntries(Object.entries(actions).filter(([, entry]) => isActionVisibleForOAuthScope(entry, effectiveIdentity?.oauthScopes)));
|
|
1120
|
-
const fullCatalogRequested = explicitlyRequestsFullMcpCatalog(requestMeta);
|
|
1121
1177
|
// Compact/connector is the DEFAULT for every caller — hosted connectors,
|
|
1122
1178
|
// code clients (Claude Code / Cursor / Codex), and the local CLI alike. The
|
|
1123
1179
|
// full ~105-tool catalog is served only on the explicit opt-in above, so a
|
|
1124
1180
|
// host can never dump every action schema into one giant tool card. The
|
|
1125
1181
|
// `mcp:apps` scope still lands on this compact MCP-Apps surface; with no
|
|
1126
1182
|
// opt-in, everyone else does too.
|
|
1127
|
-
const compactMcpAppCatalog = !fullCatalogRequested;
|
|
1183
|
+
const compactMcpAppCatalog = !appCatalog && !fullCatalogRequested;
|
|
1128
1184
|
const advertisedActionsBeforeConnector = compactMcpAppCatalog
|
|
1129
1185
|
? Object.fromEntries(Object.entries(visibleActions).filter(([name, entry]) => isActionAdvertisedInCompactMcpAppCatalog(name, entry, config)))
|
|
1130
1186
|
: visibleActions;
|
|
@@ -1140,28 +1196,32 @@ export async function createMCPServerForRequest(config, identity, requestMeta) {
|
|
|
1140
1196
|
// authenticated reads from `externalAgents.authenticatedReads: "auto"`.
|
|
1141
1197
|
// This stays compact by default and keeps db-exec / seed-* / extension /
|
|
1142
1198
|
// browser-session footguns off the external surface.
|
|
1143
|
-
const connectorCatalogActive =
|
|
1199
|
+
const connectorCatalogActive = !appCatalog &&
|
|
1200
|
+
(connectorNames.size > 0 || automaticConnectorPolicyActive) &&
|
|
1144
1201
|
!fullCatalogRequested;
|
|
1145
1202
|
// When the connector catalog is active, filter directly from visibleActions
|
|
1146
1203
|
// rather than advertisedActionsBeforeConnector. This ensures the connector
|
|
1147
1204
|
// tier is an independent, template-declared surface that doesn't accidentally
|
|
1148
1205
|
// narrow to just the compact-catalog builtins when shouldUseCompactMcpCatalogByDefault
|
|
1149
1206
|
// would have activated the compact catalog for the same caller.
|
|
1150
|
-
const
|
|
1151
|
-
? Object.fromEntries(Object.entries(visibleActions).filter(([name
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1207
|
+
const advertisedActionsBeforeToolSearchScope = appCatalog
|
|
1208
|
+
? Object.fromEntries(Object.entries(visibleActions).filter(([name]) => !denyNames.has(name)))
|
|
1209
|
+
: connectorCatalogActive
|
|
1210
|
+
? Object.fromEntries(Object.entries(visibleActions).filter(([name, entry]) => {
|
|
1211
|
+
if (denyNames.has(name))
|
|
1212
|
+
return false;
|
|
1213
|
+
if (COMPACT_MCP_APP_CATALOG_BUILTINS.has(name))
|
|
1214
|
+
return true;
|
|
1215
|
+
if (!connectorNames.has(name))
|
|
1216
|
+
return false;
|
|
1217
|
+
if (externalAgentWritesAreAskAppOnly(config) &&
|
|
1218
|
+
entry.readOnly !== true) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1155
1221
|
return true;
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
entry.readOnly !== true) {
|
|
1160
|
-
return false;
|
|
1161
|
-
}
|
|
1162
|
-
return true;
|
|
1163
|
-
}))
|
|
1164
|
-
: advertisedActionsBeforeConnector;
|
|
1222
|
+
}))
|
|
1223
|
+
: advertisedActionsBeforeConnector;
|
|
1224
|
+
const advertisedActions = scopeToolSearchToAdvertised(advertisedActionsBeforeToolSearchScope);
|
|
1165
1225
|
if (fullCatalogRequested) {
|
|
1166
1226
|
warnFullCatalogServed(Object.keys(advertisedActions).length);
|
|
1167
1227
|
}
|
|
@@ -1389,8 +1449,10 @@ export async function createMCPServerForRequest(config, identity, requestMeta) {
|
|
|
1389
1449
|
annotations,
|
|
1390
1450
|
};
|
|
1391
1451
|
}));
|
|
1392
|
-
|
|
1393
|
-
|
|
1452
|
+
// `ask-agent` is the legacy full-catalog meta-tool; `ask_app` is the
|
|
1453
|
+
// builtin every other tier carries. Gate on the one flag that means
|
|
1454
|
+
// "this caller opted all the way in".
|
|
1455
|
+
if (fullCatalogRequested &&
|
|
1394
1456
|
config.askAgent &&
|
|
1395
1457
|
hasMcpOAuthScope(effectiveIdentity?.oauthScopes, "mcp:write")) {
|
|
1396
1458
|
tools.push({
|
|
@@ -1436,7 +1498,7 @@ export async function createMCPServerForRequest(config, identity, requestMeta) {
|
|
|
1436
1498
|
return withCallerContext(async () => {
|
|
1437
1499
|
const { name, arguments: args } = request.params;
|
|
1438
1500
|
if (name === "ask-agent" && config.askAgent) {
|
|
1439
|
-
if (
|
|
1501
|
+
if (!fullCatalogRequested) {
|
|
1440
1502
|
return {
|
|
1441
1503
|
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
1442
1504
|
isError: true,
|
|
@@ -1483,12 +1545,14 @@ export async function createMCPServerForRequest(config, identity, requestMeta) {
|
|
|
1483
1545
|
};
|
|
1484
1546
|
}
|
|
1485
1547
|
}
|
|
1486
|
-
//
|
|
1487
|
-
//
|
|
1488
|
-
//
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1548
|
+
// Every tier except the explicit full-catalog opt-in treats the
|
|
1549
|
+
// advertised set as the authoritative callable surface: a name that
|
|
1550
|
+
// was not listed is rejected, not merely hidden. Deriving this from
|
|
1551
|
+
// the one opt-in flag rather than re-testing each tier is what keeps a
|
|
1552
|
+
// newly added tier from silently defaulting to "everything callable".
|
|
1553
|
+
const callableActions = fullCatalogRequested
|
|
1554
|
+
? actions
|
|
1555
|
+
: advertisedActions;
|
|
1492
1556
|
const entry = callableActions[name];
|
|
1493
1557
|
if (!entry) {
|
|
1494
1558
|
return {
|