/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: fdf3bdc60c23 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AuthConfig, AuthConfig$inboundSchema, AuthConfig$Outbound, AuthConfig$outboundSchema, } from "./authconfig.js"; import { ObjectPermissions, ObjectPermissions$inboundSchema, ObjectPermissions$Outbound, ObjectPermissions$outboundSchema, } from "./objectpermissions.js"; import { PersonObject, PersonObject$inboundSchema, PersonObject$Outbound, PersonObject$outboundSchema, } from "./personobject.js"; /** * The type of tool. */ export const ToolMetadataType = { Retrieval: "RETRIEVAL", Action: "ACTION", } as const; /** * The type of tool. */ export type ToolMetadataType = OpenEnum; /** * Indicates the kind of knowledge a tool would access or modify. */ export const KnowledgeType = { NeutralKnowledge: "NEUTRAL_KNOWLEDGE", CompanyKnowledge: "COMPANY_KNOWLEDGE", WorldKnowledge: "WORLD_KNOWLEDGE", } as const; /** * Indicates the kind of knowledge a tool would access or modify. */ export type KnowledgeType = OpenEnum; /** * Valid only for write actions. Represents the type of write action. REDIRECT - The client renders the URL which contains information for carrying out the action. EXECUTION - Send a request to an external server and execute the action. MCP - Send a tools/call request to an MCP server to execute the action. */ export const WriteActionType = { Redirect: "REDIRECT", Execution: "EXECUTION", Mcp: "MCP", } as const; /** * Valid only for write actions. Represents the type of write action. REDIRECT - The client renders the URL which contains information for carrying out the action. EXECUTION - Send a request to an external server and execute the action. MCP - Send a tools/call request to an MCP server to execute the action. */ export type WriteActionType = OpenEnum; /** * The type of authentication being used. * * @remarks * Use 'OAUTH_*' when Glean calls an external API (e.g., Jira) on behalf of a user to obtain an OAuth token. * 'OAUTH_ADMIN' utilizes an admin token for external API calls on behalf all users. * 'OAUTH_USER' uses individual user tokens for external API calls. * 'DWD' refers to domain wide delegation. */ export const AuthType = { None: "NONE", OauthUser: "OAUTH_USER", OauthAdmin: "OAUTH_ADMIN", ApiKey: "API_KEY", BasicAuth: "BASIC_AUTH", Dwd: "DWD", } as const; /** * The type of authentication being used. * * @remarks * Use 'OAUTH_*' when Glean calls an external API (e.g., Jira) on behalf of a user to obtain an OAuth token. * 'OAUTH_ADMIN' utilizes an admin token for external API calls on behalf all users. * 'OAUTH_USER' uses individual user tokens for external API calls. * 'DWD' refers to domain wide delegation. */ export type AuthType = OpenEnum; /** * The manifest for a tool that can be used to augment Glean Assistant. */ export type ToolMetadata = { /** * The type of tool. */ type: ToolMetadataType; /** * Unique identifier for the tool. Name should be understandable by the LLM, and will be used to invoke a tool. */ name: string; /** * Human understandable name of the tool. Max 50 characters. */ displayName: string; /** * An opaque id which is unique identifier for the tool. */ toolId?: string | undefined; /** * Description of the tool meant for a human. */ displayDescription: string; /** * URL used to fetch the logo. */ logoUrl?: string | undefined; /** * Name of the generated object. This will be used to indicate to the end user what the generated object contains. */ objectName?: string | undefined; /** * Indicates the kind of knowledge a tool would access or modify. */ knowledgeType?: KnowledgeType | undefined; createdBy?: PersonObject | undefined; lastUpdatedBy?: PersonObject | undefined; /** * The time the tool was created in ISO format (ISO 8601) */ createdAt?: Date | undefined; /** * The time the tool was last updated in ISO format (ISO 8601) */ lastUpdatedAt?: Date | undefined; /** * Valid only for write actions. Represents the type of write action. REDIRECT - The client renders the URL which contains information for carrying out the action. EXECUTION - Send a request to an external server and execute the action. MCP - Send a tools/call request to an MCP server to execute the action. */ writeActionType?: WriteActionType | undefined; /** * The type of authentication being used. * * @remarks * Use 'OAUTH_*' when Glean calls an external API (e.g., Jira) on behalf of a user to obtain an OAuth token. * 'OAUTH_ADMIN' utilizes an admin token for external API calls on behalf all users. * 'OAUTH_USER' uses individual user tokens for external API calls. * 'DWD' refers to domain wide delegation. */ authType?: AuthType | undefined; /** * Config for tool's authentication method. */ auth?: AuthConfig | undefined; permissions?: ObjectPermissions | undefined; /** * Usage instructions for the LLM to use this action. */ usageInstructions?: string | undefined; /** * Whether this action has been fully configured and validated. */ isSetupFinished?: boolean | undefined; }; /** @internal */ export const ToolMetadataType$inboundSchema: z.ZodType< ToolMetadataType, z.ZodTypeDef, unknown > = openEnums.inboundSchema(ToolMetadataType); /** @internal */ export const ToolMetadataType$outboundSchema: z.ZodType< string, z.ZodTypeDef, ToolMetadataType > = openEnums.outboundSchema(ToolMetadataType); /** @internal */ export const KnowledgeType$inboundSchema: z.ZodType< KnowledgeType, z.ZodTypeDef, unknown > = openEnums.inboundSchema(KnowledgeType); /** @internal */ export const KnowledgeType$outboundSchema: z.ZodType< string, z.ZodTypeDef, KnowledgeType > = openEnums.outboundSchema(KnowledgeType); /** @internal */ export const WriteActionType$inboundSchema: z.ZodType< WriteActionType, z.ZodTypeDef, unknown > = openEnums.inboundSchema(WriteActionType); /** @internal */ export const WriteActionType$outboundSchema: z.ZodType< string, z.ZodTypeDef, WriteActionType > = openEnums.outboundSchema(WriteActionType); /** @internal */ export const AuthType$inboundSchema: z.ZodType< AuthType, z.ZodTypeDef, unknown > = openEnums.inboundSchema(AuthType); /** @internal */ export const AuthType$outboundSchema: z.ZodType< string, z.ZodTypeDef, AuthType > = openEnums.outboundSchema(AuthType); /** @internal */ export const ToolMetadata$inboundSchema: z.ZodType< ToolMetadata, z.ZodTypeDef, unknown > = z.object({ type: ToolMetadataType$inboundSchema, name: z.string(), displayName: z.string(), toolId: z.string().optional(), displayDescription: z.string(), logoUrl: z.string().optional(), objectName: z.string().optional(), knowledgeType: KnowledgeType$inboundSchema.optional(), createdBy: PersonObject$inboundSchema.optional(), lastUpdatedBy: PersonObject$inboundSchema.optional(), createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), lastUpdatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), writeActionType: WriteActionType$inboundSchema.optional(), authType: AuthType$inboundSchema.optional(), auth: AuthConfig$inboundSchema.optional(), permissions: ObjectPermissions$inboundSchema.optional(), usageInstructions: z.string().optional(), isSetupFinished: z.boolean().optional(), }); /** @internal */ export type ToolMetadata$Outbound = { type: string; name: string; displayName: string; toolId?: string | undefined; displayDescription: string; logoUrl?: string | undefined; objectName?: string | undefined; knowledgeType?: string | undefined; createdBy?: PersonObject$Outbound | undefined; lastUpdatedBy?: PersonObject$Outbound | undefined; createdAt?: string | undefined; lastUpdatedAt?: string | undefined; writeActionType?: string | undefined; authType?: string | undefined; auth?: AuthConfig$Outbound | undefined; permissions?: ObjectPermissions$Outbound | undefined; usageInstructions?: string | undefined; isSetupFinished?: boolean | undefined; }; /** @internal */ export const ToolMetadata$outboundSchema: z.ZodType< ToolMetadata$Outbound, z.ZodTypeDef, ToolMetadata > = z.object({ type: ToolMetadataType$outboundSchema, name: z.string(), displayName: z.string(), toolId: z.string().optional(), displayDescription: z.string(), logoUrl: z.string().optional(), objectName: z.string().optional(), knowledgeType: KnowledgeType$outboundSchema.optional(), createdBy: PersonObject$outboundSchema.optional(), lastUpdatedBy: PersonObject$outboundSchema.optional(), createdAt: z.date().transform(v => v.toISOString()).optional(), lastUpdatedAt: z.date().transform(v => v.toISOString()).optional(), writeActionType: WriteActionType$outboundSchema.optional(), authType: AuthType$outboundSchema.optional(), auth: AuthConfig$outboundSchema.optional(), permissions: ObjectPermissions$outboundSchema.optional(), usageInstructions: z.string().optional(), isSetupFinished: z.boolean().optional(), }); export function toolMetadataToJSON(toolMetadata: ToolMetadata): string { return JSON.stringify(ToolMetadata$outboundSchema.parse(toolMetadata)); } export function toolMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ToolMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ToolMetadata' from JSON`, ); }