pull/715/head
Travis Fischer 2025-06-24 18:27:10 -05:00
rodzic d6252451f3
commit 7759aa43d3
3 zmienionych plików z 8 dodań i 23 usunięć

Wyświetl plik

@ -1,13 +0,0 @@
import { timingSafeEqual } from 'node:crypto'
export function timingSafeCompare(a: string, b: string): boolean {
if (typeof a !== 'string' || typeof b !== 'string') {
return false
}
if (a.length !== b.length) {
return false
}
return timingSafeEqual(Buffer.from(a), Buffer.from(b))
}

Wyświetl plik

@ -6,7 +6,6 @@ import { Hono } from 'hono'
import { z } from 'zod' import { z } from 'zod'
import { type Env, parseEnv } from './env' import { type Env, parseEnv } from './env'
import { timingSafeCompare } from './utils'
let serper: SerperClient let serper: SerperClient
@ -65,10 +64,8 @@ export default {
async (args, { _meta }) => { async (args, { _meta }) => {
// Make sure the request is coming from Agentic // Make sure the request is coming from Agentic
assert( assert(
timingSafeCompare( (_meta?.agentic as any)?.agenticProxySecret ===
(_meta?.agentic as any)?.agenticProxySecret, parsedEnv.AGENTIC_PROXY_SECRET,
parsedEnv.AGENTIC_PROXY_SECRET
),
400, 400,
'Invalid request' 'Invalid request'
) )

Wyświetl plik

@ -16,8 +16,7 @@ import defaultKy, { type KyInstance } from 'ky'
* *
* @example * @example
* ```ts * ```ts
* const client = await AgenticToolClient.fromIdentifier('@agentic/search') * const searchTool = await AgenticToolClient.fromIdentifier('@agentic/search')
* const result = await client.functions.get('search').execute('search query')
* ``` * ```
*/ */
export class AgenticToolClient extends AIFunctionsProvider { export class AgenticToolClient extends AIFunctionsProvider {
@ -41,6 +40,8 @@ export class AgenticToolClient extends AIFunctionsProvider {
}) { }) {
super() super()
// TODO: add support for optional apiKey
this.project = project this.project = project
this.deployment = deployment this.deployment = deployment
this.agenticGatewayBaseUrl = agenticGatewayBaseUrl this.agenticGatewayBaseUrl = agenticGatewayBaseUrl
@ -82,9 +83,9 @@ export class AgenticToolClient extends AIFunctionsProvider {
* *
* @example * @example
* ```ts * ```ts
* const client1 = await AgenticToolClient.fromIdentifier('@agentic/search') * const searchTool = await AgenticToolClient.fromIdentifier('@agentic/search')
* const client2 = await AgenticToolClient.fromIdentifier('@agentic/search@v1.0.0') * const searchToolV1 = await AgenticToolClient.fromIdentifier('@agentic/search@v1.0.0')
* const client3 = await AgenticToolClient.fromIdentifier('@agentic/search@latest') * const searchToolLatest = await AgenticToolClient.fromIdentifier('@agentic/search@latest')
* ``` * ```
*/ */
static async fromIdentifier( static async fromIdentifier(