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'
|
import type { ToolCallArgs } from './types'
|
||||||
|
|
||||||
export async function createRequestForOpenAPIOperation({
|
export async function createHttpRequestForOpenAPIOperation({
|
||||||
toolCallArgs,
|
toolCallArgs,
|
||||||
operation,
|
operation,
|
||||||
deployment,
|
deployment,
|
|
@ -85,11 +85,6 @@ export class DurableMcpServer extends McpAgent<
|
||||||
const tool = tools.find((tool) => tool.name === name)
|
const tool = tools.find((tool) => tool.name === name)
|
||||||
assert(tool, 404, `Unknown tool: ${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: rate-limiting
|
||||||
// TODO: caching
|
// TODO: caching
|
||||||
// TODO: usage tracking / reporting
|
// 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
|
ToolCallArgs
|
||||||
} from './types'
|
} from './types'
|
||||||
import { cfValidateJsonSchema } from './cf-validate-json-schema'
|
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 { enforceRateLimit } from './enforce-rate-limit'
|
||||||
import { fetchCache } from './fetch-cache'
|
import { fetchCache } from './fetch-cache'
|
||||||
import { getRequestCacheKey } from './get-request-cache-key'
|
import { getRequestCacheKey } from './get-request-cache-key'
|
||||||
import { updateOriginRequest } from './update-origin-request'
|
import { updateOriginRequest } from './update-origin-request'
|
||||||
|
|
||||||
// type State = { counter: number }
|
|
||||||
|
|
||||||
export type ResolvedOriginToolCallResult = {
|
export type ResolvedOriginToolCallResult = {
|
||||||
toolCallArgs: ToolCallArgs
|
toolCallArgs: ToolCallArgs
|
||||||
originRequest?: Request
|
originRequest?: Request
|
||||||
|
@ -158,7 +156,7 @@ export async function resolveOriginToolCall({
|
||||||
assert(operation, 404, `Tool "${tool.name}" not found in OpenAPI spec`)
|
assert(operation, 404, `Tool "${tool.name}" not found in OpenAPI spec`)
|
||||||
assert(toolCallArgs, 500)
|
assert(toolCallArgs, 500)
|
||||||
|
|
||||||
const originRequest = await createRequestForOpenAPIOperation({
|
const originRequest = await createHttpRequestForOpenAPIOperation({
|
||||||
toolCallArgs,
|
toolCallArgs,
|
||||||
operation,
|
operation,
|
||||||
deployment
|
deployment
|
||||||
|
@ -184,7 +182,7 @@ export async function resolveOriginToolCall({
|
||||||
originResponse
|
originResponse
|
||||||
}
|
}
|
||||||
} else if (originAdapter.type === 'mcp') {
|
} 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)
|
const originMcpClient = env.DO_MCP_CLIENT.get(id)
|
||||||
|
|
||||||
await originMcpClient.init({
|
await originMcpClient.init({
|
||||||
|
@ -201,7 +199,7 @@ export async function resolveOriginToolCall({
|
||||||
const originMcpRequestMetadata = {
|
const originMcpRequestMetadata = {
|
||||||
agenticProxySecret: deployment._secret,
|
agenticProxySecret: deployment._secret,
|
||||||
sessionId,
|
sessionId,
|
||||||
// ip,
|
ip,
|
||||||
isCustomerSubscriptionActive: !!consumer?.isStripeSubscriptionActive,
|
isCustomerSubscriptionActive: !!consumer?.isStripeSubscriptionActive,
|
||||||
customerId: consumer?.id,
|
customerId: consumer?.id,
|
||||||
customerSubscriptionPlan: consumer?.plan,
|
customerSubscriptionPlan: consumer?.plan,
|
||||||
|
|
|
@ -73,7 +73,10 @@ export function updateOriginRequest(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (consumer.plan) {
|
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) {
|
if (consumer.user.name) {
|
||||||
|
|
Ładowanie…
Reference in New Issue