diff --git a/apps/gateway/src/lib/create-request-for-openapi-operation.ts b/apps/gateway/src/lib/create-http-request-for-openapi-operation.ts similarity index 98% rename from apps/gateway/src/lib/create-request-for-openapi-operation.ts rename to apps/gateway/src/lib/create-http-request-for-openapi-operation.ts index dab12775..499942b5 100644 --- a/apps/gateway/src/lib/create-request-for-openapi-operation.ts +++ b/apps/gateway/src/lib/create-http-request-for-openapi-operation.ts @@ -6,7 +6,7 @@ import { assert } from '@agentic/platform-core' import type { ToolCallArgs } from './types' -export async function createRequestForOpenAPIOperation({ +export async function createHttpRequestForOpenAPIOperation({ toolCallArgs, operation, deployment, diff --git a/apps/gateway/src/lib/durable-mcp-server.ts b/apps/gateway/src/lib/durable-mcp-server.ts index 5aea4645..a179cc7c 100644 --- a/apps/gateway/src/lib/durable-mcp-server.ts +++ b/apps/gateway/src/lib/durable-mcp-server.ts @@ -85,11 +85,6 @@ export class DurableMcpServer extends McpAgent< const tool = tools.find((tool) => tool.name === name) assert(tool, 404, `Unknown tool: ${name}`) - // TODO: Implement tool config logic - // const toolConfig = deployment.toolConfigs.find( - // (toolConfig) => toolConfig.name === tool.name - // ) - // TODO: rate-limiting // TODO: caching // TODO: usage tracking / reporting @@ -122,9 +117,4 @@ export class DurableMcpServer extends McpAgent< } }) } - - // override onStateUpdate(state: State) { - // // eslint-disable-next-line no-console - // console.log({ stateUpdate: state }) - // } } diff --git a/apps/gateway/src/lib/resolve-origin-tool-call.ts b/apps/gateway/src/lib/resolve-origin-tool-call.ts index 89a34c06..d50edcc7 100644 --- a/apps/gateway/src/lib/resolve-origin-tool-call.ts +++ b/apps/gateway/src/lib/resolve-origin-tool-call.ts @@ -15,14 +15,12 @@ import type { ToolCallArgs } from './types' import { cfValidateJsonSchema } from './cf-validate-json-schema' -import { createRequestForOpenAPIOperation } from './create-request-for-openapi-operation' +import { createHttpRequestForOpenAPIOperation } from './create-http-request-for-openapi-operation' import { enforceRateLimit } from './enforce-rate-limit' import { fetchCache } from './fetch-cache' import { getRequestCacheKey } from './get-request-cache-key' import { updateOriginRequest } from './update-origin-request' -// type State = { counter: number } - export type ResolvedOriginToolCallResult = { toolCallArgs: ToolCallArgs originRequest?: Request @@ -158,7 +156,7 @@ export async function resolveOriginToolCall({ assert(operation, 404, `Tool "${tool.name}" not found in OpenAPI spec`) assert(toolCallArgs, 500) - const originRequest = await createRequestForOpenAPIOperation({ + const originRequest = await createHttpRequestForOpenAPIOperation({ toolCallArgs, operation, deployment @@ -184,7 +182,7 @@ export async function resolveOriginToolCall({ originResponse } } else if (originAdapter.type === 'mcp') { - const id: DurableObjectId = env.DO_MCP_CLIENT.idFromName(sessionId) + const id = env.DO_MCP_CLIENT.idFromName(sessionId) const originMcpClient = env.DO_MCP_CLIENT.get(id) await originMcpClient.init({ @@ -201,7 +199,7 @@ export async function resolveOriginToolCall({ const originMcpRequestMetadata = { agenticProxySecret: deployment._secret, sessionId, - // ip, + ip, isCustomerSubscriptionActive: !!consumer?.isStripeSubscriptionActive, customerId: consumer?.id, customerSubscriptionPlan: consumer?.plan, diff --git a/apps/gateway/src/lib/update-origin-request.ts b/apps/gateway/src/lib/update-origin-request.ts index 13284d8c..9b44525c 100644 --- a/apps/gateway/src/lib/update-origin-request.ts +++ b/apps/gateway/src/lib/update-origin-request.ts @@ -73,7 +73,10 @@ export function updateOriginRequest( ) if (consumer.plan) { - originRequest.headers.set('x-agentic-plan', consumer.plan) + originRequest.headers.set( + 'x-agentic-customer-subscription-plan', + consumer.plan + ) } if (consumer.user.name) {