fix: small fixes for example ts sdk usage and gateway

pull/714/head
Travis Fischer 2025-06-29 04:00:47 -05:00
rodzic 65a16d8453
commit 938be099df
6 zmienionych plików z 17 dodań i 10 usunięć

Wyświetl plik

@ -109,7 +109,8 @@ app.all(async (ctx) => {
} else { } else {
originResponse = await createHttpResponseFromMcpToolCallResponse(ctx, { originResponse = await createHttpResponseFromMcpToolCallResponse(ctx, {
...resolvedHttpEdgeRequest, ...resolvedHttpEdgeRequest,
toolCallResponse: resolvedOriginToolCallResult.toolCallResponse toolCallResponse: resolvedOriginToolCallResult.toolCallResponse,
toolConfig: resolvedOriginToolCallResult.toolConfig
}) })
} }

Wyświetl plik

@ -1,4 +1,4 @@
import type { AdminDeployment, Tool } from '@agentic/platform-types' import type { AdminDeployment, Tool, ToolConfig } from '@agentic/platform-types'
import { assert } from '@agentic/platform-core' import { assert } from '@agentic/platform-core'
import type { GatewayHonoContext, McpToolCallResponse } from './types' import type { GatewayHonoContext, McpToolCallResponse } from './types'
@ -9,11 +9,13 @@ export async function createHttpResponseFromMcpToolCallResponse(
{ {
tool, tool,
deployment, deployment,
toolCallResponse toolCallResponse,
toolConfig
}: { }: {
tool: Tool tool: Tool
deployment: AdminDeployment deployment: AdminDeployment
toolCallResponse: McpToolCallResponse toolCallResponse: McpToolCallResponse
toolConfig?: ToolConfig
} }
): Promise<Response> { ): Promise<Response> {
assert( assert(
@ -29,6 +31,12 @@ export async function createHttpResponseFromMcpToolCallResponse(
) )
if (tool.outputSchema) { if (tool.outputSchema) {
// eslint-disable-next-line no-console
console.log(`tool call "${tool.name}" structured response:`, {
outputSchema: tool.outputSchema,
toolCallResponse
})
assert( assert(
toolCallResponse.structuredContent, toolCallResponse.structuredContent,
502, 502,
@ -41,7 +49,8 @@ export async function createHttpResponseFromMcpToolCallResponse(
data: toolCallResponse.structuredContent as Record<string, unknown>, data: toolCallResponse.structuredContent as Record<string, unknown>,
coerce: false, coerce: false,
// TODO: double-check MCP schema on whether additional properties are allowed // TODO: double-check MCP schema on whether additional properties are allowed
strictAdditionalProperties: true, strictAdditionalProperties:
toolConfig?.outputSchemaAdditionalProperties === false,
errorPrefix: `Invalid tool response for tool "${tool.name}"`, errorPrefix: `Invalid tool response for tool "${tool.name}"`,
errorStatusCode: 502 errorStatusCode: 502
}) })

Wyświetl plik

@ -21,7 +21,7 @@ async function main() {
prompt: 'What is the weather in San Francisco?' prompt: 'What is the weather in San Francisco?'
}) })
console.log(result.toolResults[0]) console.log(JSON.stringify(result.toolResults[0], null, 2))
} }
await main() await main()

Wyświetl plik

@ -18,7 +18,7 @@ async function main() {
prompt: 'What is the weather in San Francisco?' prompt: 'What is the weather in San Francisco?'
}) })
console.log(result.toolResults[0]) console.log(JSON.stringify(result.toolResults[0], null, 2))
} }
await main() await main()

Wyświetl plik

@ -1,4 +0,0 @@
import { calculator } from '@agentic/calculator'
defTool(calculator)
$`Answer the following arithmetic question: How much is 11 + 4? then divide by 3?`

Wyświetl plik

@ -26,6 +26,7 @@
- add caching to public projects api endpoints - add caching to public projects api endpoints
- add support for [`@google/genai`](https://github.com/googleapis/js-genai) tools adapter and examples - add support for [`@google/genai`](https://github.com/googleapis/js-genai) tools adapter and examples
- fix gateway sentry deployment upload - fix gateway sentry deployment upload
- add feature about optimized context to marketing site
## TODO: Post-MVP ## TODO: Post-MVP