kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/715/head
rodzic
ee4c33c69c
commit
fb1f67a685
|
@ -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,
|
|
@ -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 })
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
Ładowanie…
Reference in New Issue