mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use tools through connectors: catalog connectors, custom MCP
servers, and aggregator gateways (Composio, Arcade, Executor) that reach
many apps
> - Connector telemetry sends every custom MCP connector as
`connector_key: "custom"`, and it sends nothing about apps behind an
aggregator
> - The team cannot see which services people add as custom servers, or
which aggregator apps people try to connect and which ones they finish
> - This pull request adds a reduced `server_domain` to the connection
events for custom connectors, and two aggregator app events
> - The benefit is a privacy-safe view of connector demand: no URL, no
subdomain, and no provider-controlled string leaves the installation
## Linked Issues or Issue Description
No issue exists. This follows the feature request template
(`.github/ISSUE_TEMPLATE/feature_request.yml`).
**Subsystem affected**
Server connector telemetry
(`server/src/services/connector-telemetry.ts`), the aggregator app sync
and setup paths
(`server/src/services/tool-access/catalog/aggregator-accounts.ts`), the
tool gateway, and the shared telemetry contract
(`packages/shared/src/telemetry`).
**Problem or motivation**
Connector telemetry sends every connector outside the first-party
catalog as `connector_key: "custom"`, and every app behind Composio as
the `composio` connector. Arcade and Executor apps are hidden the same
way. This hides which servers and apps people actually connect to. It
also hides what they try to connect and fail to connect. The team cannot
use telemetry to decide which connectors to add to the catalog or where
setup fails.
**Proposed solution**
For custom connectors only, send the registrable domain of the server
(`server_domain`), with IP, private, and local hosts reduced to
`private` and stdio servers to `stdio`. Send `connection.app_requested`
when a person or agent asks an aggregator to add an app, with the
result, and `connection.app_linked` when that app becomes connected. The
app is a slug from the checked-in aggregator catalog, or `other`. No
user-controlled string leaves the process.
**Alternatives considered**
Sending the full host was rejected: subdomains can name a customer or
tenant. Hashing the host was rejected: it cannot be read in an insight,
and short domains are easy to reverse. Sending the provider's toolkit
name was rejected: Executor and custom integrations use names that
people choose.
## What Changed
- Sync the generated telemetry contract. The telemetry backend registers
`server_domain` and the two new events first, so nothing is dropped as
unregistered.
- `server/src/services/connector-telemetry.ts`:
- `serverDomainForUrl()` reduces a configured address to its registrable
domain (ICANN public suffix plus one label, from `tldts`).
`mcp.smithery.ai/sse?token=…` becomes `smithery.ai`. IPs, loopback,
single-label hosts, non-ICANN or special-use suffixes (`.local`,
`.internal`, `.home.arpa`, `.onion`), non-HTTP schemes, and unparsable
values become `private`. A final pattern check makes sure nothing
URL-shaped can pass.
- `server_domain` goes on `connection.created`, `connection.updated`,
and `connection.invoked` only when `connector_key` is `custom`. Local
stdio servers send `stdio`. A remote connection with no address yet
omits it.
- `aggregatorAppTelemetrySlug()` returns a slug from the shared
aggregator catalog, or `other`. This is the same rule as
`connector_key`.
- `newlyLinkedToolkits()`, `emitAggregatorAppsLinked()`,
`emitAggregatorAppsRequested()`, and
`emitAggregatorAppRequestsFromToolCall()`. All are best-effort and never
throw.
- `aggregator-accounts.ts`: the Composio list check and the
Arcade/Executor inventory sync read the previous snapshot status before
the write. They send `connection.app_linked` only for a change to
`connected`. The Composio check sends it right after each saved row, so
a later app that fails in the same check does not lose it, and it
updates the stored status after each write, so an app named twice in one
check sends one event. The Composio upsert now returns its row, so a
write that loses to a newer observation sends nothing. App setup `start`
and account `add` send `connection.app_requested` (`origin: user`) with
`succeeded`, `needs_auth`, or `failed`.
- `tool-gateway.ts`: one call after the remote MCP response is parsed.
An agent's `COMPOSIO_MANAGE_CONNECTIONS` call with `add` sends one
`connection.app_requested` (`origin: agent`) per app.
`composioAddOutcomes()` parses the response once and reads each app's
own result node: connected is `succeeded`, its own sign-in link is
`needs_auth`, an error or no node is `failed`. A sibling's link never
counts; the response-wide link counts only when one app was added. An
Arcade tool call that answers with an authorization step sends
`needs_auth`.
- `connection-methods.ts`: `remoteEndpointValue()` shares the `url` →
`endpoint` → `remoteUrl` order with `remoteEndpoint()`.
- `server/package.json`: add `tldts` 7.4.10 as a direct dependency. It
is already in the lockfile through `tough-cookie`. The lockfile is left
to CI.
- Shared telemetry: typed helpers `trackConnectionAppLinked` and
`trackConnectionAppRequested`, `server_domain` on the three connection
helpers, retention class `operational_enum_count` for the new events,
and a "Connector Events" section in the telemetry README.
## New Dependency
`tldts` 7.4.10 (MIT) is added to `server/package.json`.
- Why: `server_domain` must be the registrable domain (eTLD+1), so
`mcp.example.co.uk` gives `example.co.uk` and not `co.uk`. That needs
the Public Suffix List. No runtime dependency in the repo parses it.
`new URL()` and `node:net` give only the hostname and IP detection.
Splitting on the last two labels is wrong for multi-part suffixes such
as `co.uk` and would leak or merge domains.
- Already in the tree: `tldts` 7.4.10 is in `pnpm-lock.yaml` through
`jsdom` → `tough-cookie`, a dev-only path. This PR makes it a direct
server dependency at the same version, so no new package is downloaded.
- Size: about 125 KB minified (`dist/index.cjs.min.js`), with one
dependency, `tldts-core` (same author). It bundles the suffix list, so
it does no network or file reads at run time.
- Maintenance: actively maintained (latest release this month), widely
used (it is the suffix parser in `tough-cookie`), with typed exports.
## Verification
- `pnpm exec vitest run src/services/connector-telemetry.test.ts`
(server): 65 pass, including a sibling's link, a top-level link with
several apps, and the one-app fallback. New cases cover domain reduction
(paths with tokens, userinfo, ports, uppercase, trailing dot, IDN,
`github.io` and `vercel.app` subdomains dropped), `private` for IPv4,
IPv6, loopback, `.local`, `.internal`, `.home.arpa`, `.onion`,
single-label, unknown suffix, `ftp:`, and non-strings, a payload check
that no part of a secret-bearing URL appears in any of the three events,
catalog-or-`other` for every provider, a check that every catalog slug
matches the registered `app` pattern, and the transition rule.
- `pnpm exec vitest run src/__tests__/composio-app-setup.test.ts
src/__tests__/aggregator-app-sync.test.ts` (embedded Postgres): 36 pass,
including an app named twice in one check (fails without the fix).
Composio: setup `start` sends one `needs_auth` request; refreshes while
the account is only initiated send nothing; activation sends exactly one
`app_linked` over three refreshes and a `complete`; an app saved before
a later app fails in the same check keeps its `app_linked`; an
unconfirmed `add` sends `failed`. Executor: two syncs send one
`app_linked`; a disconnect sends nothing. Agent requests: mixed per-app
results give `succeeded`, `needs_auth`, and `failed` separately.
- Red check: with the previous-status check or the domain reduction
removed, 13 of these tests fail.
- `pnpm exec vitest run src/telemetry` (shared): 46 pass, including the
real client sending `server_domain` and both new events.
- Related suites still pass: connector telemetry for tool access and the
gateway, Circleback parity, aggregator fallback, connection intents, MCP
protocol versions, MCP tasks, remote MCP connectors, remote MCP pending
(265 tests).
- `tsc --noEmit` reports no errors in the changed files.
- `tests/runner-e2e/source-sdk-public-inputs.json` is regenerated with
`node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --write`,
because it pins the shared telemetry files. `--check` and
`source-sdk-public-inputs.test.mjs` (13) pass.
- CI note: on d501fe5272, `General tests (server (5/12))` failed on a 15
s timeout in
`src/services/native-runtime/provider-pack-archive.test.ts`. That test
does not touch this change, and it passes locally (52/52). `Build` and
`e2e shard (2/8)` were cancelled by a runner shutdown. The next push
re-ran all three.
## Privacy Review
Privacy review: approved by repo owner (@cryppadotta) on 2026-11-23, for
sending the registrable domain of custom MCP servers, with domains seen
in fewer than 3 workspaces hidden in dashboards.
Privacy review requested. This is a Telemetry change under
`rules/data-paths.mdc`: it updates the generated contract and the
telemetry README, and it adds one reduced host value. Please confirm:
- `server_domain` is sent only for `connector_key: "custom"`. It holds
only the registrable domain. The path, query, port, credentials, and
subdomains are dropped in the app, and the registered schema pattern
rejects them too.
- IP, loopback, private, single-label, and special-use hosts send the
fixed value `private`. Local servers send `stdio`.
- `app` on the two new events is a slug from the checked-in aggregator
catalog, or `other`. The provider's toolkit string, app name, and
account name are never sent.
- `provider`, `origin`, and `outcome` are closed enums.
- Retention for the two new events is `operational_enum_count` (90
days).
- Analyses must hide domains seen in fewer than 3 workspaces.
## Risks
- Low product risk. Every emitter catches its own errors, and the
gateway call sits before existing control flow without changing it.
- Privacy: a self-hosted MCP server on a personal domain still sends
that domain. Analyses hide domains seen in fewer than 3 workspaces.
- `connection.app_linked` is best-effort. Two syncs for the same person
that run at the same time can both read the old status and send twice.
- Agent requests that fail before a response is parsed (HTTP error,
timeout) are not counted. Executor approval steps are not counted as app
requests.
- Each agent retry of a call that needs authorization sends one more
`needs_auth` request.
## Model Used
Claude Opus 5.5 (`claude-opus-5-5`) via Claude Code, with tool use and
code execution.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
376 lines
13 KiB
TypeScript
376 lines
13 KiB
TypeScript
import { parseRemoteHttpEndpoint } from "../remote-http-endpoint-guard.js";
|
|
import type { AppDefinition, ConnectionMethodDef, ToolConnectionTransport } from "@paperclipai/shared";
|
|
import {
|
|
credentialConfigPath,
|
|
getAvailableConnectionMethod,
|
|
getAvailableConnectionMethods,
|
|
getConnectableAppDefinition,
|
|
resolveConnectionMethodServerUrl,
|
|
checkMcpRemoteHeaderName,
|
|
checkMcpRemoteHeaderValue,
|
|
mcpRemoteHeaderRejectionMessage,
|
|
} from "@paperclipai/shared";
|
|
import { badRequest, unprocessable } from "../../errors.js";
|
|
import { isPaperclipCloudConnectorStrategy } from "../paperclip-cloud-connector.js";
|
|
import { honchoManagedArguments } from "../honcho-connection.js";
|
|
import { assertGoogleChatToolArgumentsSupported, googleChatToolInputSchema } from "../google-chat-tool-policy.js";
|
|
import { gmailArchiveToolInputSchema } from "../gmail-archive-tool-policy.js";
|
|
import { githubOwnerToolInputSchema } from "./github-default-owner.js";
|
|
|
|
type ConnectionSettings = {
|
|
config: Record<string, unknown>;
|
|
transport: ToolConnectionTransport;
|
|
transportConfig?: Record<string, unknown>;
|
|
};
|
|
|
|
function asRecord(value: unknown): Record<string, unknown> {
|
|
if (value && typeof value === "object" && !Array.isArray(value))
|
|
return value as Record<string, unknown>;
|
|
return {};
|
|
}
|
|
|
|
export function connectionMethodFor(app: AppDefinition, methodKey?: string | null) {
|
|
const normalizedMethodKey =
|
|
app.slug === "gmail" && methodKey === "paperclip-id-oauth"
|
|
? "paperclip-draft"
|
|
: methodKey;
|
|
// Stored managed connections must remain recognizable for callback, refresh,
|
|
// and revoke even though static definitions omit instance availability. New
|
|
// setup passes a definition filtered by signed profiles before reaching here;
|
|
// the broker independently enforces availability on authorization and refresh.
|
|
const availableMethods = new Set(getAvailableConnectionMethods(app));
|
|
const toolMethods = app.methods.filter(
|
|
(candidate) =>
|
|
candidate.purpose !== "channel" && candidate.purpose !== "ai"
|
|
&& candidate.transport !== "chat_sdk" && candidate.transport !== "runtime_auth"
|
|
&& (availableMethods.has(candidate) || isPaperclipCloudConnectorStrategy(candidate.oauthStrategy)),
|
|
);
|
|
const method = normalizedMethodKey
|
|
? (toolMethods.find((candidate) => candidate.key === normalizedMethodKey) ??
|
|
null)
|
|
: getAvailableConnectionMethod({ ...app, methods: toolMethods }, null);
|
|
if (!method)
|
|
throw unprocessable(
|
|
"This app does not have an available connection method",
|
|
);
|
|
return method;
|
|
}
|
|
|
|
export function connectionMethodForConnection(
|
|
app: AppDefinition,
|
|
connection: ConnectionSettings,
|
|
) {
|
|
const methodKey =
|
|
typeof connection.config.connectionMethodKey === "string"
|
|
? connection.config.connectionMethodKey
|
|
: null;
|
|
return connectionMethodFor(app, methodKey);
|
|
}
|
|
|
|
export function credentialFieldsFor(app: AppDefinition, methodKey?: string | null) {
|
|
const method = connectionMethodFor(app, methodKey);
|
|
return (method.credentialFields ?? []).map((field) => ({
|
|
label: field.label,
|
|
configPath: credentialConfigPath(field, method),
|
|
helpUrl: method.consoleLinks?.keys ?? method.consoleLinks?.docs ?? "",
|
|
required: field.required,
|
|
placement:
|
|
method.keyPlacement?.location === "header"
|
|
? ("header" as const)
|
|
: undefined,
|
|
key: method.keyPlacement?.name,
|
|
prefix: method.keyPlacement?.prefix,
|
|
}));
|
|
}
|
|
|
|
|
|
export function normalizeConnectionMethodConfig(
|
|
method: ConnectionMethodDef,
|
|
configValues: Record<string, unknown> | undefined,
|
|
): {
|
|
values: Record<string, string | boolean>;
|
|
url?: string;
|
|
headers?: Record<string, string>;
|
|
} {
|
|
const fields = [
|
|
...(method.tenantFields ?? []),
|
|
...(method.extensionFields ?? []),
|
|
];
|
|
const allowedKeys = new Set(fields.map((field) => field.key));
|
|
for (const key of Object.keys(configValues ?? {})) {
|
|
if (!allowedKeys.has(key))
|
|
throw badRequest(`Unknown connection setting: ${key}`);
|
|
}
|
|
|
|
const values: Record<string, string | boolean> = {};
|
|
for (const field of fields) {
|
|
const raw = configValues?.[field.key] ?? field.defaultValue;
|
|
if (field.type === "checkbox") {
|
|
if (raw !== undefined && typeof raw !== "boolean")
|
|
throw badRequest(`${field.label} must be true or false`);
|
|
if (raw !== undefined) values[field.key] = raw;
|
|
continue;
|
|
}
|
|
if (raw !== undefined && typeof raw !== "string")
|
|
throw badRequest(`${field.label} must be text`);
|
|
let value = raw?.trim() ?? "";
|
|
if (field.transport?.format === "csv") {
|
|
value = Array.from(
|
|
new Set(
|
|
value
|
|
.split(/[\n,]/g)
|
|
.map((entry) => entry.trim())
|
|
.filter(Boolean),
|
|
),
|
|
).join(",");
|
|
}
|
|
if (field.required && !value)
|
|
throw badRequest(`Missing connection setting: ${field.label}`);
|
|
if (!value) continue;
|
|
if (
|
|
field.validation?.maxLength &&
|
|
value.length > field.validation.maxLength
|
|
) {
|
|
throw badRequest(
|
|
`${field.label} must be at most ${field.validation.maxLength} characters`,
|
|
);
|
|
}
|
|
if (
|
|
field.validation?.pattern &&
|
|
!new RegExp(field.validation.pattern).test(value)
|
|
) {
|
|
throw badRequest(`${field.label} has an invalid value`);
|
|
}
|
|
if (
|
|
field.type === "select" &&
|
|
!field.options?.some((option) => option.value === value)
|
|
) {
|
|
throw badRequest(`${field.label} has an invalid option`);
|
|
}
|
|
values[field.key] = value;
|
|
}
|
|
for (const keys of method.configRequirements?.atLeastOneOf
|
|
? [method.configRequirements.atLeastOneOf]
|
|
: []) {
|
|
if (
|
|
!keys.some(
|
|
(key) => typeof values[key] === "string" && values[key].length > 0,
|
|
)
|
|
) {
|
|
throw badRequest(`Provide at least one of: ${keys.join(", ")}`);
|
|
}
|
|
}
|
|
|
|
const resolvedServerUrl = resolveConnectionMethodServerUrl(method, values);
|
|
if (method.defaults?.serverUrlTemplate && !resolvedServerUrl) {
|
|
throw badRequest(
|
|
"Missing or invalid connection settings for the server URL",
|
|
);
|
|
}
|
|
const endpoint = resolvedServerUrl ? new URL(resolvedServerUrl) : null;
|
|
if (endpoint && endpoint.protocol !== "https:") {
|
|
throw badRequest("Connection server URL must use HTTPS");
|
|
}
|
|
const headers: Record<string, string> = {};
|
|
for (const field of fields) {
|
|
const transport = field.transport;
|
|
const value = values[field.key];
|
|
if (
|
|
!transport ||
|
|
value === undefined ||
|
|
(value === false && transport.omitFalse)
|
|
)
|
|
continue;
|
|
const serialized = typeof value === "boolean" ? String(value) : value;
|
|
if (transport.location === "query")
|
|
endpoint?.searchParams.set(transport.name, serialized);
|
|
else {
|
|
const nameCheck = checkMcpRemoteHeaderName(transport.name);
|
|
const valueCheck = checkMcpRemoteHeaderValue(serialized);
|
|
if (!nameCheck.ok || !valueCheck.ok) {
|
|
throw badRequest(
|
|
mcpRemoteHeaderRejectionMessage(
|
|
transport.name,
|
|
nameCheck.reason ?? valueCheck.reason!,
|
|
),
|
|
);
|
|
}
|
|
headers[transport.name] = serialized;
|
|
}
|
|
}
|
|
return {
|
|
values,
|
|
...(endpoint ? { url: endpoint.toString() } : {}),
|
|
...(Object.keys(headers).length > 0 ? { headers } : {}),
|
|
};
|
|
}
|
|
|
|
export function projectedConnectionHeaders(
|
|
connection: ConnectionSettings,
|
|
): Record<string, string> {
|
|
const sourceTemplateKey =
|
|
typeof connection.config.sourceTemplateKey === "string"
|
|
? connection.config.sourceTemplateKey
|
|
: null;
|
|
const app = sourceTemplateKey
|
|
? getConnectableAppDefinition(sourceTemplateKey)
|
|
: null;
|
|
const headers: Record<string, string> = {};
|
|
if (app) {
|
|
const method = connectionMethodForConnection(app, connection);
|
|
// Non-transport settings do not participate in header projection. In
|
|
// particular, legacy connections can lack a newly introduced setting.
|
|
if ([...(method.tenantFields ?? []), ...(method.extensionFields ?? [])].some((field) => field.transport?.location === "header")) {
|
|
Object.assign(headers, normalizeConnectionMethodConfig(
|
|
method,
|
|
asRecord(connection.config.methodConfig),
|
|
).headers);
|
|
}
|
|
}
|
|
if (
|
|
connection.transport === "mcp_remote" &&
|
|
(sourceTemplateKey === "github" || connection.transportConfig?.sourceTemplateKey === "github")
|
|
) {
|
|
// GitHub excludes Actions from its default catalog. Project this on every
|
|
// discovery and invocation so existing connections gain the toolset too.
|
|
headers["X-MCP-Toolsets"] = "default,actions";
|
|
}
|
|
return headers;
|
|
}
|
|
|
|
function mergeManagedToolArguments(
|
|
supplied: Record<string, unknown>,
|
|
managed: Record<string, unknown>,
|
|
): Record<string, unknown> {
|
|
const merged = { ...supplied };
|
|
for (const [key, value] of Object.entries(managed)) {
|
|
const suppliedValue = merged[key];
|
|
merged[key] =
|
|
asRecord(value) === value && asRecord(suppliedValue) === suppliedValue
|
|
? mergeManagedToolArguments(
|
|
suppliedValue as Record<string, unknown>,
|
|
value as Record<string, unknown>,
|
|
)
|
|
: value;
|
|
}
|
|
return merged;
|
|
}
|
|
|
|
export function projectConnectionMethodToolArguments(
|
|
method: ConnectionMethodDef,
|
|
parameters: unknown,
|
|
): Record<string, unknown> {
|
|
const supplied = asRecord(parameters);
|
|
const managed = method.defaults?.toolArgumentDefaults;
|
|
return managed ? mergeManagedToolArguments(supplied, managed) : supplied;
|
|
}
|
|
|
|
function stripManagedToolArgumentSchema(
|
|
schema: Record<string, unknown>,
|
|
managed: Record<string, unknown>,
|
|
): Record<string, unknown> {
|
|
const properties = asRecord(schema.properties);
|
|
if (Object.keys(properties).length === 0) return schema;
|
|
const nextProperties = { ...properties };
|
|
for (const [key, managedValue] of Object.entries(managed)) {
|
|
const propertySchema = asRecord(nextProperties[key]);
|
|
const managedRecord = asRecord(managedValue);
|
|
if (
|
|
Object.keys(propertySchema).length === 0 ||
|
|
Object.keys(managedRecord).length === 0
|
|
) {
|
|
delete nextProperties[key];
|
|
continue;
|
|
}
|
|
const projectedProperty = stripManagedToolArgumentSchema(
|
|
propertySchema,
|
|
managedRecord,
|
|
);
|
|
if (Object.keys(asRecord(projectedProperty.properties)).length === 0)
|
|
delete nextProperties[key];
|
|
else nextProperties[key] = projectedProperty;
|
|
}
|
|
const nextSchema: Record<string, unknown> = {
|
|
...schema,
|
|
properties: nextProperties,
|
|
};
|
|
if (Array.isArray(schema.required)) {
|
|
const required = schema.required.filter(
|
|
(key): key is string => typeof key === "string" && key in nextProperties,
|
|
);
|
|
if (required.length > 0) nextSchema.required = required;
|
|
else delete nextSchema.required;
|
|
}
|
|
return nextSchema;
|
|
}
|
|
|
|
export function projectConnectionMethodToolInputSchema(
|
|
method: ConnectionMethodDef,
|
|
inputSchema: Record<string, unknown>,
|
|
): Record<string, unknown> {
|
|
const managed = method.defaults?.toolArgumentDefaults;
|
|
return managed
|
|
? stripManagedToolArgumentSchema(inputSchema, managed)
|
|
: inputSchema;
|
|
}
|
|
|
|
export function projectedConnectionToolArguments(
|
|
connection: ConnectionSettings,
|
|
parameters: unknown,
|
|
toolName: string,
|
|
inputSchema: Record<string, unknown> = {},
|
|
): Record<string, unknown> {
|
|
const managed = honchoManagedArguments(connection, inputSchema);
|
|
if (managed) parameters = mergeManagedToolArguments(asRecord(parameters), managed);
|
|
assertGoogleChatToolArgumentsSupported(connection, toolName, parameters);
|
|
const sourceTemplateKey =
|
|
typeof connection.config.sourceTemplateKey === "string"
|
|
? connection.config.sourceTemplateKey
|
|
: null;
|
|
const app = sourceTemplateKey
|
|
? getConnectableAppDefinition(sourceTemplateKey)
|
|
: null;
|
|
if (!app) return asRecord(parameters);
|
|
return projectConnectionMethodToolArguments(
|
|
connectionMethodForConnection(app, connection),
|
|
parameters,
|
|
);
|
|
}
|
|
|
|
export function projectedConnectionToolInputSchema(
|
|
connection: ConnectionSettings,
|
|
inputSchema: Record<string, unknown>,
|
|
toolName: string,
|
|
): Record<string, unknown> {
|
|
const managed = honchoManagedArguments(connection, inputSchema);
|
|
if (managed) inputSchema = stripManagedToolArgumentSchema(inputSchema, managed);
|
|
inputSchema = googleChatToolInputSchema(connection, toolName, inputSchema);
|
|
inputSchema = gmailArchiveToolInputSchema(connection, toolName, inputSchema);
|
|
inputSchema = githubOwnerToolInputSchema(connection, toolName, inputSchema);
|
|
const sourceTemplateKey =
|
|
typeof connection.config.sourceTemplateKey === "string"
|
|
? connection.config.sourceTemplateKey
|
|
: null;
|
|
const app = sourceTemplateKey
|
|
? getConnectableAppDefinition(sourceTemplateKey)
|
|
: null;
|
|
if (!app) return inputSchema;
|
|
return projectConnectionMethodToolInputSchema(
|
|
connectionMethodForConnection(app, connection),
|
|
inputSchema,
|
|
);
|
|
}
|
|
|
|
/** The configured remote address, before validation: `url`, then `endpoint`, then `remoteUrl`. */
|
|
export function remoteEndpointValue(config: Record<string, unknown>): unknown {
|
|
return config.url ?? config.endpoint ?? config.remoteUrl;
|
|
}
|
|
|
|
export function remoteEndpoint(config: Record<string, unknown>): string {
|
|
const value = remoteEndpointValue(config);
|
|
const parsed = parseRemoteHttpEndpoint(value, (message, code) =>
|
|
badRequest(message, { code }),
|
|
);
|
|
return parsed.toString();
|
|
}
|