/** A subset of JSON Schema sufficient for OpenAI function parameters. */ export interface JsonSchema { type: string; properties?: Record; required?: string[]; description?: string; items?: JsonSchema; enum?: unknown[]; [key: string]: unknown; } /** OpenAI / AutoGen function-calling tool definition. */ export interface OpenAIFunctionTool { type: 'function'; function: { name: string; description: string; parameters: JsonSchema; }; } /** Options for {@link createGrantexFunction}. */ export interface GrantexFunctionOptions> { /** Function name shown to the LLM. Must match `^[a-zA-Z0-9_-]+$`. */ name: string; /** Human-readable description shown to the LLM. */ description: string; /** JSON Schema describing the structured input arguments. */ parameters: JsonSchema; /** Grantex grant token obtained from the token exchange. */ grantToken: string; /** JWKS URL used to verify the grant token. Defaults to https://api.grantex.dev/.well-known/jwks.json. */ jwksUri?: string; /** Expected JWT issuer when it differs from the JWKS origin. */ issuer?: string; /** did:web issuer used to derive the JWKS URL. */ issuerDid?: string; /** Expected JWT audience. */ audience?: string; /** Opt-in current issuer authority and trusted host identity binding. Requires audience. */ currentAuthority?: (token: string) => Promise; expectedPrincipalId?: string; expectedAgentDid?: string; /** Clock tolerance in seconds for token verification. */ clockTolerance?: number; /** Scope the agent must hold to invoke this function (e.g. `'calendar:read'`). */ requiredScope: string; /** The function implementation. Receives typed args, returns any JSON-serialisable value. */ func: (args: T) => Promise; } /** * A Grantex-authorized function in OpenAI function-calling format. * * - `definition` — pass this to the LLM (inside a `tools` array) * - `execute(args)` — call after the LLM selects the tool; verifies token and scope */ export interface GrantexFunction> { /** OpenAI function-calling tool definition for passing to the LLM. */ readonly definition: OpenAIFunctionTool; /** * Execute the function with the given arguments. * Verifies the grant token and required scope before calling `func`. * Throws if the agent does not hold the required scope. */ execute(args: T): Promise; } //# sourceMappingURL=types.d.ts.map