Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

53.3 KB
Raw Blame
/* Generated by scripts/generate-dcs-tools.ts
 * *DO NOT EDIT MANUALLY*
 */

import type { ResultError } from '@core/util/result';
import { err, ok, type Result } from 'neverthrow';
import { bookingLinkHistory } from '../../booking-link-history';
import * as schemas from './schemas';
import type * as types from './types';

type ToolParserMap = {
  AddSharedCalendarEvent: {
    call: types.AddSharedCalendarEvent;
    response: types.ToolCalendarEvent;
  };
  AddToPipeline: {
    call: types.AddToPipeline;
    response: types.AddToPipelineResponse;
  };
  ApplyCanvasEdits: {
    call: types.ApplyCanvasEdits;
    response: types.CanvasResponse;
  };
  BashCodeExecution: {
    call: types.BashCodeExecution;
    response: types.BashCodeExecutionResponse;
  };
  BulkSetEntityPropertyOptions: {
    call: types.BulkSetEntityPropertyOptions;
    response: types.BulkSetEntityPropertyOptionsResponse;
  };
  CalculateSpreadsheet: {
    call: types.CalculateSpreadsheet;
    response: types.SpreadsheetResponse;
  };
  ChangeBooking: { call: types.ChangeBooking; response: types.Booking };
  Comment: { call: types.Comment; response: types.CommentResponse };
  CommentOnText: {
    call: types.CommentOnText;
    response: types.CommentOnTextResponse;
  };
  ConfigureAgent: {
    call: types.ConfigureAgent;
    response: types.ConfigureAgentResponse;
  };
  ConfigureBot: {
    call: types.ConfigureBot;
    response: types.ConfigureBotResponse;
  };
  ConnectMcpServer: {
    call: types.ConnectMcpServer;
    response: types.ConnectMcpServerResponse;
  };
  ContentSearch: {
    call: types.ContentSearch;
    response: types.SearchToolResponse;
  };
  CreateAgentSession: {
    call: types.CreateAgentSession;
    response: types.DispatchedCodingAgent;
  };
  CreateBookingLink: {
    call: types.CreateBookingLink;
    response: types.BookingLinkResult;
  };
  CreateBot: { call: types.CreateBot; response: types.CreateBotResponse };
  CreateCalendarEvent: {
    call: types.CreateCalendarEvent;
    response: types.UserToolResponseForToolCalendarEvent;
  };
  CreateChannel: {
    call: types.CreateChannel;
    response: types.CreateChannelResponse;
  };
  CreateCompany: {
    call: types.CreateCompany;
    response: types.CreateCompanyResponse;
  };
  CreateConfirmedCalendarEvent: {
    call: types.CreateConfirmedCalendarEvent;
    response: types.ToolCalendarEvent;
  };
  CreateContact: {
    call: types.CreateContact;
    response: types.CreateContactResponse;
  };
  CreateDocument: {
    call: types.CreateDocument;
    response: types.CreateDocumentResponse;
  };
  CreateForm: { call: types.CreateForm; response: types.MutationResult };
  CreateImportEntity: {
    call: types.CreateImportEntity;
    response: types.CreateImportEntityResponse;
  };
  CreateInitiative: {
    call: types.CreateInitiative;
    response: types.ProjectDetails;
  };
  CreatePipeline: {
    call: types.CreatePipeline;
    response: types.CreatePipelineResponse;
  };
  CreateProject: {
    call: types.CreateProject;
    response: types.CreateProjectResponse;
  };
  CreateRoutine: { call: types.CreateRoutine; response: types.RoutineInfo };
  CreateSkill: { call: types.CreateSkill; response: types.CreateSkillResponse };
  CreateTag: { call: types.CreateTag; response: types.CreateTagResponse };
  Decide: { call: types.Decide; response: types.DecisionResponse };
  DeleteBot: { call: types.DeleteBot; response: types.DeleteBotResponse };
  DeleteCalendarEvent: {
    call: types.DeleteCalendarEvent;
    response: types.DeleteCalendarEventResponse;
  };
  DeleteCallRecord: {
    call: types.DeleteCallRecord;
    response: types.DeleteCallRecordResponse;
  };
  DeleteChannelMessage: {
    call: types.DeleteChannelMessage;
    response: types.DeleteChannelMessageResponse;
  };
  DeleteComment: {
    call: types.DeleteComment;
    response: types.DeleteCommentResponse;
  };
  DeleteDatabaseView: {
    call: types.DeleteDatabaseView;
    response: types.DeletedDatabaseView;
  };
  DeleteImportEntity: {
    call: types.DeleteImportEntity;
    response: types.DeleteImportEntityResponse;
  };
  DeleteInitiative: {
    call: types.DeleteInitiative;
    response: types.ProjectOperationComplete;
  };
  DeleteRoutine: { call: types.DeleteRoutine; response: types.DeletedRoutine };
  DeleteTag: { call: types.DeleteTag; response: types.DeleteTagResponse };
  DescribeCodeTools: {
    call: types.DescribeCodeTools;
    response: types.CodeToolsDescription;
  };
  DescribeDatabase: {
    call: types.DescribeDatabase;
    response: types.ToolDatabaseSchema;
  };
  DiscoverConnectors: {
    call: types.DiscoverConnectors;
    response: types.DiscoverConnectorsResponse;
  };
  DispatchCodingAgent: {
    call: types.DispatchCodingAgent;
    response: types.DispatchedCodingAgent;
  };
  DuplicateItem: {
    call: types.DuplicateItem;
    response: types.DuplicateItemResponse;
  };
  EditBookingLink: {
    call: types.EditBookingLink;
    response: types.BookingLinkResult;
  };
  EditCanvas: { call: types.EditCanvas; response: types.CanvasResponse };
  EditChannelMessage: {
    call: types.EditChannelMessage;
    response: types.EditChannelMessageResponse;
  };
  EditComment: { call: types.EditComment; response: types.EditCommentResponse };
  EditDocument: {
    call: types.EditDocument;
    response: types.EditDocumentResponse;
  };
  EditForm: { call: types.EditForm; response: types.MutationResult };
  EditPipeline: {
    call: types.EditPipeline;
    response: types.EditPipelineResponse;
  };
  EditPresentation: {
    call: types.EditPresentation;
    response: types.PresentationEditOutcome;
  };
  EditSpreadsheet: {
    call: types.EditSpreadsheet;
    response: types.SpreadsheetResponse;
  };
  EditTag: { call: types.EditTag; response: types.EditTagResponse };
  EditWordDocument: {
    call: types.EditWordDocument;
    response: types.WordDocumentResponse;
  };
  ExecuteCode: { call: types.ExecuteCode; response: types.ExecutionReceipt };
  ExportPipelineCsv: {
    call: types.ExportPipelineCsv;
    response: types.ExportPipelineCsvResponse;
  };
  FindPipelineEntries: {
    call: types.FindPipelineEntries;
    response: types.FindPipelineEntriesResponse;
  };
  GenerateImage: {
    call: types.GenerateImage;
    response: types.GenerateImageResponse;
  };
  GenerateObject: {
    call: types.GenerateObject;
    response: types.GenerateObjectResponse;
  };
  GetBookingInsights: {
    call: types.GetBookingInsights;
    response: types.BookingInsights;
  };
  GetBookingRescheduleSlots: {
    call: types.GetBookingRescheduleSlots;
    response: types.BookingSlotsResult;
  };
  GetBotWebhooks: {
    call: types.GetBotWebhooks;
    response: types.GetBotWebhooksResponse;
  };
  GetCompany: { call: types.GetCompany; response: types.GetCompanyResponse };
  GetEntityProperties: {
    call: types.GetEntityProperties;
    response: types.GetEntityPropertiesResponse;
  };
  GetTeamAvailability: {
    call: types.GetTeamAvailability;
    response: types.TeamAvailability;
  };
  GetThread: { call: types.GetThread; response: types.GetThreadResponse };
  GetUserActivity: {
    call: types.GetUserActivity;
    response: types.ActivityReports;
  };
  ImportCompaniesCsv: {
    call: types.ImportCompaniesCsv;
    response: types.ImportCompaniesCsvResponse;
  };
  ImportFromJira: {
    call: types.ImportFromJira;
    response: types.TrackerImportResponse;
  };
  ImportFromLinear: {
    call: types.ImportFromLinear;
    response: types.TrackerImportResponse;
  };
  ImportFromNotion: {
    call: types.ImportFromNotion;
    response: types.ImportFromNotionResponse;
  };
  ImportNotionPage: {
    call: types.ImportNotionPage;
    response: types.ImportNotionPageResponse;
  };
  ImportPipelineCsv: {
    call: types.ImportPipelineCsv;
    response: types.ImportPipelineCsvResponse;
  };
  IssueBotCredential: {
    call: types.IssueBotCredential;
    response: types.IssueBotCredentialResponse;
  };
  ListAgents: { call: types.ListAgents; response: types.ListAgentsResponse };
  ListAgentUpdates: {
    call: types.ListAgentUpdates;
    response: types.AgentUpdates;
  };
  ListBookingLinks: {
    call: types.ListBookingLinks;
    response: types.ListBookingLinksResult;
  };
  ListBookings: { call: types.ListBookings; response: types.BookingsResult };
  ListBots: { call: types.ListBots; response: types.ListBotsResponse };
  ListCalendarEvents: {
    call: types.ListCalendarEvents;
    response: types.ListCalendarEventsResponse;
  };
  ListCalendars: {
    call: types.ListCalendars;
    response: types.ListCalendarsToolResponse;
  };
  ListCodingAgents: {
    call: types.ListCodingAgents;
    response: types.ListCodingAgentsResponse;
  };
  ListCompanies: {
    call: types.ListCompanies;
    response: types.ListCompaniesResponse;
  };
  ListDatabases: {
    call: types.ListDatabases;
    response: types.ListDatabasesResponse;
  };
  ListEntities: {
    call: types.ListEntities;
    response: types.ListEntitiesResponse;
  };
  ListForms: { call: types.ListForms; response: types.ListResult };
  ListImportEntities: {
    call: types.ListImportEntities;
    response: types.ListImportEntitiesResponse;
  };
  ListInboxes: { call: types.ListInboxes; response: types.ListInboxesResponse };
  ListInitiatives: {
    call: types.ListInitiatives;
    response: types.ProjectListResult;
  };
  ListLabels: { call: types.ListLabels; response: types.ListLabelsResponse };
  ListNotifications: {
    call: types.ListNotifications;
    response: types.ListNotificationsResponse;
  };
  ListPipelines: {
    call: types.ListPipelines;
    response: types.ListPipelinesResponse;
  };
  ListRoutines: { call: types.ListRoutines; response: types.RoutineList };
  ListSkills: { call: types.ListSkills; response: types.ListSkillsResponse };
  ListTags: { call: types.ListTags; response: types.ListTagsResponse };
  ListTeamMembers: {
    call: types.ListTeamMembers;
    response: types.ListTeamMembersResponse;
  };
  LoadTools: { call: types.LoadTools; response: types.LoadToolsResponse };
  ManageAgentSession: {
    call: types.ManageAgentSession;
    response: types.SessionActionResult;
  };
  ManageBotChannelAccess: {
    call: types.ManageBotChannelAccess;
    response: types.ManageBotChannelAccessResponse;
  };
  ManageChannelParticipants: {
    call: types.ManageChannelParticipants;
    response: types.ManageChannelParticipantsResponse;
  };
  MarkNotificationsDone: {
    call: types.MarkNotificationsDone;
    response: types.MarkNotificationsResponse;
  };
  MarkNotificationsSeen: {
    call: types.MarkNotificationsSeen;
    response: types.MarkNotificationsResponse;
  };
  MoveToProject: {
    call: types.MoveToProject;
    response: types.MoveToProjectResponse;
  };
  MoveToTrash: { call: types.MoveToTrash; response: types.MoveToTrashResponse };
  MuteNotifications: {
    call: types.MuteNotifications;
    response: types.MuteNotificationsResponse;
  };
  NameSearch: { call: types.NameSearch; response: types.SearchToolResponse };
  OpenDirectMessage: {
    call: types.OpenDirectMessage;
    response: types.OpenDirectMessageResponse;
  };
  QueryDatabase: {
    call: types.QueryDatabase;
    response: types.QueryDatabaseResponse;
  };
  ReactToChannelMessage: {
    call: types.ReactToChannelMessage;
    response: types.ReactToChannelMessageResponse;
  };
  ReadActivity: {
    call: types.ReadActivity;
    response: types.ReadActivityResponse;
  };
  ReadAgentSession: {
    call: types.ReadAgentSession;
    response: types.SessionConversation;
  };
  ReadAgentSessionSharing: {
    call: types.ReadAgentSessionSharing;
    response: types.SessionSharingResponse;
  };
  ReadBookingSettings: {
    call: types.ReadBookingSettings;
    response: types.BookingSettingsResult;
  };
  ReadCalendarEvent: {
    call: types.ReadCalendarEvent;
    response: types.ReadCalendarEventResponse;
  };
  ReadCallRecord: {
    call: types.ReadCallRecord;
    response: types.ReadCallRecordResponse;
  };
  ReadCanvas: { call: types.ReadCanvas; response: types.CanvasResponse };
  ReadChannelMessageContext: {
    call: types.ReadChannelMessageContext;
    response: types.ReadChannelMessageContextResponse;
  };
  ReadChannelMessages: {
    call: types.ReadChannelMessages;
    response: types.ReadChannelMessagesResponse;
  };
  ReadChannelThread: {
    call: types.ReadChannelThread;
    response: types.ReadChannelThreadResponse;
  };
  ReadChat: { call: types.ReadChat; response: types.ReadChatResponse };
  ReadCodeDocs: { call: types.ReadCodeDocs; response: types.SymbolReferences };
  ReadContent: { call: types.ReadContent; response: types.ReadContentResponse };
  ReadDesign: { call: types.ReadDesign; response: types.ReadDesignResponse };
  ReadDiscussion: {
    call: types.ReadDiscussion;
    response: types.ReadDiscussionResponse;
  };
  ReadForm: { call: types.ReadForm; response: types.ReadResult };
  ReadIllustratorDocument: {
    call: types.ReadIllustratorDocument;
    response: types.ReadIllustratorDocumentResponse;
  };
  ReadInitiative: {
    call: types.ReadInitiative;
    response: types.ProjectReadResult;
  };
  ReadInitiativeActivity: {
    call: types.ReadInitiativeActivity;
    response: types.ProjectActivityResult;
  };
  ReadMemory: { call: types.ReadMemory; response: types.ExplicitMemory };
  ReadMetadata: {
    call: types.ReadMetadata;
    response: types.ReadMetadataResponse;
  };
  ReadPhotoshopDocument: {
    call: types.ReadPhotoshopDocument;
    response: types.ReadPhotoshopDocumentResponse;
  };
  ReadPresentation: {
    call: types.ReadPresentation;
    response: types.ReadPresentationResponse;
  };
  ReadProject: { call: types.ReadProject; response: types.ReadProjectResponse };
  ReadRoutine: { call: types.ReadRoutine; response: types.RoutineDetails };
  ReadSkill: { call: types.ReadSkill; response: types.ReadSkillResponse };
  ReadSpreadsheet: {
    call: types.ReadSpreadsheet;
    response: types.SpreadsheetResponse;
  };
  ReadThread: { call: types.ReadThread; response: types.ReadResponse };
  ReadWordDocument: {
    call: types.ReadWordDocument;
    response: types.WordDocumentResponse;
  };
  RemoveFromPipeline: {
    call: types.RemoveFromPipeline;
    response: types.RemoveFromPipelineResponse;
  };
  RenameChannel: {
    call: types.RenameChannel;
    response: types.RenameChannelResponse;
  };
  RenameDocument: {
    call: types.RenameDocument;
    response: types.RenameDocumentResponse;
  };
  RenameItem: { call: types.RenameItem; response: types.RenameItemResponse };
  RenderCanvas: { call: types.RenderCanvas; response: types.CanvasRender };
  ResolveComment: {
    call: types.ResolveComment;
    response: types.ResolveCommentResponse;
  };
  RunRoutine: { call: types.RunRoutine; response: types.RoutineRunStarted };
  SaveDatabaseQuery: {
    call: types.SaveDatabaseQuery;
    response: types.SaveDatabaseQueryResponse;
  };
  SaveDatabaseView: {
    call: types.SaveDatabaseView;
    response: types.SavedDatabaseView;
  };
  SearchSkills: {
    call: types.SearchSkills;
    response: types.SearchSkillsResponse;
  };
  SearchTools: { call: types.SearchTools; response: types.SearchToolsResponse };
  SelfKnowledge: {
    call: types.SelfKnowledge;
    response: types.SelfKnowledgeResponse;
  };
  SendChannelMessage: {
    call: types.SendChannelMessage;
    response: types.SendChannelMessageResponse;
  };
  SendConfirmedEmail: {
    call: types.SendConfirmedEmail;
    response: types.SendEmailResponse;
  };
  SendEmail: {
    call: types.SendEmail;
    response: types.UserToolResponseForSendEmailResponse;
  };
  SetEntityProperty: {
    call: types.SetEntityProperty;
    response: types.SetEntityPropertyResponse;
  };
  SetFavorite: { call: types.SetFavorite; response: types.SetFavoriteResponse };
  SetFormAccess: { call: types.SetFormAccess; response: types.MutationResult };
  SetSenderPolicy: {
    call: types.SetSenderPolicy;
    response: types.SetSenderPolicyResponse;
  };
  ShareWithChannel: {
    call: types.ShareWithChannel;
    response: types.ShareWithChannelResponse;
  };
  Subagent: { call: types.Subagent; response: types.SubagentResponse };
  TextEditorCodeExecution: {
    call: types.TextEditorCodeExecution;
    response: types.TextEditorCodeExecutionResponse;
  };
  UpdateAgentSessionSharing: {
    call: types.UpdateAgentSessionSharing;
    response: types.SessionSharingResponse;
  };
  UpdateBookingSettings: {
    call: types.UpdateBookingSettings;
    response: types.BookingSettingsResult;
  };
  UpdateCalendarEvent: {
    call: types.UpdateCalendarEvent;
    response: types.ToolCalendarEvent;
  };
  UpdateCallRecord: {
    call: types.UpdateCallRecord;
    response: types.UpdateCallRecordResponse;
  };
  UpdateInitiative: {
    call: types.UpdateInitiative;
    response: types.ProjectDetails;
  };
  UpdateInitiativeSharing: {
    call: types.UpdateInitiativeSharing;
    response: types.ProjectDetails;
  };
  UpdateMemory: { call: types.UpdateMemory; response: types.ExplicitMemory };
  UpdatePipelineEntries: {
    call: types.UpdatePipelineEntries;
    response: types.UpdatePipelineEntriesResponse;
  };
  UpdateRoutine: { call: types.UpdateRoutine; response: types.RoutineInfo };
  UpdateSharing: {
    call: types.UpdateSharing;
    response: types.UpdateSharingResponse;
  };
  UpdateThreadLabels: {
    call: types.UpdateThreadLabels;
    response: types.UpdateThreadLabelsResponse;
  };
  UploadFile: { call: types.UploadFile; response: types.UploadFileResponse };
  WebFetch: { call: types.WebFetch; response: types.WebFetchResponse };
  WebSearch: { call: types.WebSearch; response: types.WebSearchResponse };
};

const toolParserMap = {
  AddSharedCalendarEvent: {
    call: schemas.AddSharedCalendarEvent,
    response: schemas.ToolCalendarEvent,
  },
  AddToPipeline: {
    call: schemas.AddToPipeline,
    response: schemas.AddToPipelineResponse,
  },
  ApplyCanvasEdits: {
    call: schemas.ApplyCanvasEdits,
    response: schemas.CanvasResponse,
  },
  BashCodeExecution: {
    call: schemas.BashCodeExecution,
    response: schemas.BashCodeExecutionResponse,
  },
  BulkSetEntityPropertyOptions: {
    call: schemas.BulkSetEntityPropertyOptions,
    response: schemas.BulkSetEntityPropertyOptionsResponse,
  },
  CalculateSpreadsheet: {
    call: schemas.CalculateSpreadsheet,
    response: schemas.SpreadsheetResponse,
  },
  ChangeBooking: { call: schemas.ChangeBooking, response: schemas.Booking },
  Comment: { call: schemas.Comment, response: schemas.CommentResponse },
  CommentOnText: {
    call: schemas.CommentOnText,
    response: schemas.CommentOnTextResponse,
  },
  ConfigureAgent: {
    call: schemas.ConfigureAgent,
    response: schemas.ConfigureAgentResponse,
  },
  ConfigureBot: {
    call: schemas.ConfigureBot,
    response: schemas.ConfigureBotResponse,
  },
  ConnectMcpServer: {
    call: schemas.ConnectMcpServer,
    response: schemas.ConnectMcpServerResponse,
  },
  ContentSearch: {
    call: schemas.ContentSearch,
    response: schemas.SearchToolResponse,
  },
  CreateAgentSession: {
    call: schemas.CreateAgentSession,
    response: schemas.DispatchedCodingAgent,
  },
  CreateBookingLink: {
    call: schemas.CreateBookingLink,
    response: schemas.BookingLinkResult,
  },
  CreateBot: { call: schemas.CreateBot, response: schemas.CreateBotResponse },
  CreateCalendarEvent: {
    call: schemas.CreateCalendarEvent,
    response: schemas.UserToolResponseForToolCalendarEvent,
  },
  CreateChannel: {
    call: schemas.CreateChannel,
    response: schemas.CreateChannelResponse,
  },
  CreateCompany: {
    call: schemas.CreateCompany,
    response: schemas.CreateCompanyResponse,
  },
  CreateConfirmedCalendarEvent: {
    call: schemas.CreateConfirmedCalendarEvent,
    response: schemas.ToolCalendarEvent,
  },
  CreateContact: {
    call: schemas.CreateContact,
    response: schemas.CreateContactResponse,
  },
  CreateDocument: {
    call: schemas.CreateDocument,
    response: schemas.CreateDocumentResponse,
  },
  CreateForm: { call: schemas.CreateForm, response: schemas.MutationResult },
  CreateImportEntity: {
    call: schemas.CreateImportEntity,
    response: schemas.CreateImportEntityResponse,
  },
  CreateInitiative: {
    call: schemas.CreateInitiative,
    response: schemas.ProjectDetails,
  },
  CreatePipeline: {
    call: schemas.CreatePipeline,
    response: schemas.CreatePipelineResponse,
  },
  CreateProject: {
    call: schemas.CreateProject,
    response: schemas.CreateProjectResponse,
  },
  CreateRoutine: { call: schemas.CreateRoutine, response: schemas.RoutineInfo },
  CreateSkill: {
    call: schemas.CreateSkill,
    response: schemas.CreateSkillResponse,
  },
  CreateTag: { call: schemas.CreateTag, response: schemas.CreateTagResponse },
  Decide: { call: schemas.Decide, response: schemas.DecisionResponse },
  DeleteBot: { call: schemas.DeleteBot, response: schemas.DeleteBotResponse },
  DeleteCalendarEvent: {
    call: schemas.DeleteCalendarEvent,
    response: schemas.DeleteCalendarEventResponse,
  },
  DeleteCallRecord: {
    call: schemas.DeleteCallRecord,
    response: schemas.DeleteCallRecordResponse,
  },
  DeleteChannelMessage: {
    call: schemas.DeleteChannelMessage,
    response: schemas.DeleteChannelMessageResponse,
  },
  DeleteComment: {
    call: schemas.DeleteComment,
    response: schemas.DeleteCommentResponse,
  },
  DeleteDatabaseView: {
    call: schemas.DeleteDatabaseView,
    response: schemas.DeletedDatabaseView,
  },
  DeleteImportEntity: {
    call: schemas.DeleteImportEntity,
    response: schemas.DeleteImportEntityResponse,
  },
  DeleteInitiative: {
    call: schemas.DeleteInitiative,
    response: schemas.ProjectOperationComplete,
  },
  DeleteRoutine: {
    call: schemas.DeleteRoutine,
    response: schemas.DeletedRoutine,
  },
  DeleteTag: { call: schemas.DeleteTag, response: schemas.DeleteTagResponse },
  DescribeCodeTools: {
    call: schemas.DescribeCodeTools,
    response: schemas.CodeToolsDescription,
  },
  DescribeDatabase: {
    call: schemas.DescribeDatabase,
    response: schemas.ToolDatabaseSchema,
  },
  DiscoverConnectors: {
    call: schemas.DiscoverConnectors,
    response: schemas.DiscoverConnectorsResponse,
  },
  DispatchCodingAgent: {
    call: schemas.DispatchCodingAgent,
    response: schemas.DispatchedCodingAgent,
  },
  DuplicateItem: {
    call: schemas.DuplicateItem,
    response: schemas.DuplicateItemResponse,
  },
  EditBookingLink: {
    call: schemas.EditBookingLink,
    response: schemas.BookingLinkResult,
  },
  EditCanvas: { call: schemas.EditCanvas, response: schemas.CanvasResponse },
  EditChannelMessage: {
    call: schemas.EditChannelMessage,
    response: schemas.EditChannelMessageResponse,
  },
  EditComment: {
    call: schemas.EditComment,
    response: schemas.EditCommentResponse,
  },
  EditDocument: {
    call: schemas.EditDocument,
    response: schemas.EditDocumentResponse,
  },
  EditForm: { call: schemas.EditForm, response: schemas.MutationResult },
  EditPipeline: {
    call: schemas.EditPipeline,
    response: schemas.EditPipelineResponse,
  },
  EditPresentation: {
    call: schemas.EditPresentation,
    response: schemas.PresentationEditOutcome,
  },
  EditSpreadsheet: {
    call: schemas.EditSpreadsheet,
    response: schemas.SpreadsheetResponse,
  },
  EditTag: { call: schemas.EditTag, response: schemas.EditTagResponse },
  EditWordDocument: {
    call: schemas.EditWordDocument,
    response: schemas.WordDocumentResponse,
  },
  ExecuteCode: {
    call: schemas.ExecuteCode,
    response: schemas.ExecutionReceipt,
  },
  ExportPipelineCsv: {
    call: schemas.ExportPipelineCsv,
    response: schemas.ExportPipelineCsvResponse,
  },
  FindPipelineEntries: {
    call: schemas.FindPipelineEntries,
    response: schemas.FindPipelineEntriesResponse,
  },
  GenerateImage: {
    call: schemas.GenerateImage,
    response: schemas.GenerateImageResponse,
  },
  GenerateObject: {
    call: schemas.GenerateObject,
    response: schemas.GenerateObjectResponse,
  },
  GetBookingInsights: {
    call: schemas.GetBookingInsights,
    response: schemas.BookingInsights,
  },
  GetBookingRescheduleSlots: {
    call: schemas.GetBookingRescheduleSlots,
    response: schemas.BookingSlotsResult,
  },
  GetBotWebhooks: {
    call: schemas.GetBotWebhooks,
    response: schemas.GetBotWebhooksResponse,
  },
  GetCompany: {
    call: schemas.GetCompany,
    response: schemas.GetCompanyResponse,
  },
  GetEntityProperties: {
    call: schemas.GetEntityProperties,
    response: schemas.GetEntityPropertiesResponse,
  },
  GetTeamAvailability: {
    call: schemas.GetTeamAvailability,
    response: schemas.TeamAvailability,
  },
  GetThread: { call: schemas.GetThread, response: schemas.GetThreadResponse },
  GetUserActivity: {
    call: schemas.GetUserActivity,
    response: schemas.ActivityReports,
  },
  ImportCompaniesCsv: {
    call: schemas.ImportCompaniesCsv,
    response: schemas.ImportCompaniesCsvResponse,
  },
  ImportFromJira: {
    call: schemas.ImportFromJira,
    response: schemas.TrackerImportResponse,
  },
  ImportFromLinear: {
    call: schemas.ImportFromLinear,
    response: schemas.TrackerImportResponse,
  },
  ImportFromNotion: {
    call: schemas.ImportFromNotion,
    response: schemas.ImportFromNotionResponse,
  },
  ImportNotionPage: {
    call: schemas.ImportNotionPage,
    response: schemas.ImportNotionPageResponse,
  },
  ImportPipelineCsv: {
    call: schemas.ImportPipelineCsv,
    response: schemas.ImportPipelineCsvResponse,
  },
  IssueBotCredential: {
    call: schemas.IssueBotCredential,
    response: schemas.IssueBotCredentialResponse,
  },
  ListAgents: {
    call: schemas.ListAgents,
    response: schemas.ListAgentsResponse,
  },
  ListAgentUpdates: {
    call: schemas.ListAgentUpdates,
    response: schemas.AgentUpdates,
  },
  ListBookingLinks: {
    call: schemas.ListBookingLinks,
    response: schemas.ListBookingLinksResult,
  },
  ListBookings: {
    call: schemas.ListBookings,
    response: schemas.BookingsResult,
  },
  ListBots: { call: schemas.ListBots, response: schemas.ListBotsResponse },
  ListCalendarEvents: {
    call: schemas.ListCalendarEvents,
    response: schemas.ListCalendarEventsResponse,
  },
  ListCalendars: {
    call: schemas.ListCalendars,
    response: schemas.ListCalendarsToolResponse,
  },
  ListCodingAgents: {
    call: schemas.ListCodingAgents,
    response: schemas.ListCodingAgentsResponse,
  },
  ListCompanies: {
    call: schemas.ListCompanies,
    response: schemas.ListCompaniesResponse,
  },
  ListDatabases: {
    call: schemas.ListDatabases,
    response: schemas.ListDatabasesResponse,
  },
  ListEntities: {
    call: schemas.ListEntities,
    response: schemas.ListEntitiesResponse,
  },
  ListForms: { call: schemas.ListForms, response: schemas.ListResult },
  ListImportEntities: {
    call: schemas.ListImportEntities,
    response: schemas.ListImportEntitiesResponse,
  },
  ListInboxes: {
    call: schemas.ListInboxes,
    response: schemas.ListInboxesResponse,
  },
  ListInitiatives: {
    call: schemas.ListInitiatives,
    response: schemas.ProjectListResult,
  },
  ListLabels: {
    call: schemas.ListLabels,
    response: schemas.ListLabelsResponse,
  },
  ListNotifications: {
    call: schemas.ListNotifications,
    response: schemas.ListNotificationsResponse,
  },
  ListPipelines: {
    call: schemas.ListPipelines,
    response: schemas.ListPipelinesResponse,
  },
  ListRoutines: { call: schemas.ListRoutines, response: schemas.RoutineList },
  ListSkills: {
    call: schemas.ListSkills,
    response: schemas.ListSkillsResponse,
  },
  ListTags: { call: schemas.ListTags, response: schemas.ListTagsResponse },
  ListTeamMembers: {
    call: schemas.ListTeamMembers,
    response: schemas.ListTeamMembersResponse,
  },
  LoadTools: { call: schemas.LoadTools, response: schemas.LoadToolsResponse },
  ManageAgentSession: {
    call: schemas.ManageAgentSession,
    response: schemas.SessionActionResult,
  },
  ManageBotChannelAccess: {
    call: schemas.ManageBotChannelAccess,
    response: schemas.ManageBotChannelAccessResponse,
  },
  ManageChannelParticipants: {
    call: schemas.ManageChannelParticipants,
    response: schemas.ManageChannelParticipantsResponse,
  },
  MarkNotificationsDone: {
    call: schemas.MarkNotificationsDone,
    response: schemas.MarkNotificationsResponse,
  },
  MarkNotificationsSeen: {
    call: schemas.MarkNotificationsSeen,
    response: schemas.MarkNotificationsResponse,
  },
  MoveToProject: {
    call: schemas.MoveToProject,
    response: schemas.MoveToProjectResponse,
  },
  MoveToTrash: {
    call: schemas.MoveToTrash,
    response: schemas.MoveToTrashResponse,
  },
  MuteNotifications: {
    call: schemas.MuteNotifications,
    response: schemas.MuteNotificationsResponse,
  },
  NameSearch: {
    call: schemas.NameSearch,
    response: schemas.SearchToolResponse,
  },
  OpenDirectMessage: {
    call: schemas.OpenDirectMessage,
    response: schemas.OpenDirectMessageResponse,
  },
  QueryDatabase: {
    call: schemas.QueryDatabase,
    response: schemas.QueryDatabaseResponse,
  },
  ReactToChannelMessage: {
    call: schemas.ReactToChannelMessage,
    response: schemas.ReactToChannelMessageResponse,
  },
  ReadActivity: {
    call: schemas.ReadActivity,
    response: schemas.ReadActivityResponse,
  },
  ReadAgentSession: {
    call: schemas.ReadAgentSession,
    response: schemas.SessionConversation,
  },
  ReadAgentSessionSharing: {
    call: schemas.ReadAgentSessionSharing,
    response: schemas.SessionSharingResponse,
  },
  ReadBookingSettings: {
    call: schemas.ReadBookingSettings,
    response: schemas.BookingSettingsResult,
  },
  ReadCalendarEvent: {
    call: schemas.ReadCalendarEvent,
    response: schemas.ReadCalendarEventResponse,
  },
  ReadCallRecord: {
    call: schemas.ReadCallRecord,
    response: schemas.ReadCallRecordResponse,
  },
  ReadCanvas: { call: schemas.ReadCanvas, response: schemas.CanvasResponse },
  ReadChannelMessageContext: {
    call: schemas.ReadChannelMessageContext,
    response: schemas.ReadChannelMessageContextResponse,
  },
  ReadChannelMessages: {
    call: schemas.ReadChannelMessages,
    response: schemas.ReadChannelMessagesResponse,
  },
  ReadChannelThread: {
    call: schemas.ReadChannelThread,
    response: schemas.ReadChannelThreadResponse,
  },
  ReadChat: { call: schemas.ReadChat, response: schemas.ReadChatResponse },
  ReadCodeDocs: {
    call: schemas.ReadCodeDocs,
    response: schemas.SymbolReferences,
  },
  ReadContent: {
    call: schemas.ReadContent,
    response: schemas.ReadContentResponse,
  },
  ReadDesign: {
    call: schemas.ReadDesign,
    response: schemas.ReadDesignResponse,
  },
  ReadDiscussion: {
    call: schemas.ReadDiscussion,
    response: schemas.ReadDiscussionResponse,
  },
  ReadForm: { call: schemas.ReadForm, response: schemas.ReadResult },
  ReadIllustratorDocument: {
    call: schemas.ReadIllustratorDocument,
    response: schemas.ReadIllustratorDocumentResponse,
  },
  ReadInitiative: {
    call: schemas.ReadInitiative,
    response: schemas.ProjectReadResult,
  },
  ReadInitiativeActivity: {
    call: schemas.ReadInitiativeActivity,
    response: schemas.ProjectActivityResult,
  },
  ReadMemory: { call: schemas.ReadMemory, response: schemas.ExplicitMemory },
  ReadMetadata: {
    call: schemas.ReadMetadata,
    response: schemas.ReadMetadataResponse,
  },
  ReadPhotoshopDocument: {
    call: schemas.ReadPhotoshopDocument,
    response: schemas.ReadPhotoshopDocumentResponse,
  },
  ReadPresentation: {
    call: schemas.ReadPresentation,
    response: schemas.ReadPresentationResponse,
  },
  ReadProject: {
    call: schemas.ReadProject,
    response: schemas.ReadProjectResponse,
  },
  ReadRoutine: { call: schemas.ReadRoutine, response: schemas.RoutineDetails },
  ReadSkill: { call: schemas.ReadSkill, response: schemas.ReadSkillResponse },
  ReadSpreadsheet: {
    call: schemas.ReadSpreadsheet,
    response: schemas.SpreadsheetResponse,
  },
  ReadThread: { call: schemas.ReadThread, response: schemas.ReadResponse },
  ReadWordDocument: {
    call: schemas.ReadWordDocument,
    response: schemas.WordDocumentResponse,
  },
  RemoveFromPipeline: {
    call: schemas.RemoveFromPipeline,
    response: schemas.RemoveFromPipelineResponse,
  },
  RenameChannel: {
    call: schemas.RenameChannel,
    response: schemas.RenameChannelResponse,
  },
  RenameDocument: {
    call: schemas.RenameDocument,
    response: schemas.RenameDocumentResponse,
  },
  RenameItem: {
    call: schemas.RenameItem,
    response: schemas.RenameItemResponse,
  },
  RenderCanvas: { call: schemas.RenderCanvas, response: schemas.CanvasRender },
  ResolveComment: {
    call: schemas.ResolveComment,
    response: schemas.ResolveCommentResponse,
  },
  RunRoutine: { call: schemas.RunRoutine, response: schemas.RoutineRunStarted },
  SaveDatabaseQuery: {
    call: schemas.SaveDatabaseQuery,
    response: schemas.SaveDatabaseQueryResponse,
  },
  SaveDatabaseView: {
    call: schemas.SaveDatabaseView,
    response: schemas.SavedDatabaseView,
  },
  SearchSkills: {
    call: schemas.SearchSkills,
    response: schemas.SearchSkillsResponse,
  },
  SearchTools: {
    call: schemas.SearchTools,
    response: schemas.SearchToolsResponse,
  },
  SelfKnowledge: {
    call: schemas.SelfKnowledge,
    response: schemas.SelfKnowledgeResponse,
  },
  SendChannelMessage: {
    call: schemas.SendChannelMessage,
    response: schemas.SendChannelMessageResponse,
  },
  SendConfirmedEmail: {
    call: schemas.SendConfirmedEmail,
    response: schemas.SendEmailResponse,
  },
  SendEmail: {
    call: schemas.SendEmail,
    response: schemas.UserToolResponseForSendEmailResponse,
  },
  SetEntityProperty: {
    call: schemas.SetEntityProperty,
    response: schemas.SetEntityPropertyResponse,
  },
  SetFavorite: {
    call: schemas.SetFavorite,
    response: schemas.SetFavoriteResponse,
  },
  SetFormAccess: {
    call: schemas.SetFormAccess,
    response: schemas.MutationResult,
  },
  SetSenderPolicy: {
    call: schemas.SetSenderPolicy,
    response: schemas.SetSenderPolicyResponse,
  },
  ShareWithChannel: {
    call: schemas.ShareWithChannel,
    response: schemas.ShareWithChannelResponse,
  },
  Subagent: { call: schemas.Subagent, response: schemas.SubagentResponse },
  TextEditorCodeExecution: {
    call: schemas.TextEditorCodeExecution,
    response: schemas.TextEditorCodeExecutionResponse,
  },
  UpdateAgentSessionSharing: {
    call: schemas.UpdateAgentSessionSharing,
    response: schemas.SessionSharingResponse,
  },
  UpdateBookingSettings: {
    call: schemas.UpdateBookingSettings,
    response: schemas.BookingSettingsResult,
  },
  UpdateCalendarEvent: {
    call: schemas.UpdateCalendarEvent,
    response: schemas.ToolCalendarEvent,
  },
  UpdateCallRecord: {
    call: schemas.UpdateCallRecord,
    response: schemas.UpdateCallRecordResponse,
  },
  UpdateInitiative: {
    call: schemas.UpdateInitiative,
    response: schemas.ProjectDetails,
  },
  UpdateInitiativeSharing: {
    call: schemas.UpdateInitiativeSharing,
    response: schemas.ProjectDetails,
  },
  UpdateMemory: {
    call: schemas.UpdateMemory,
    response: schemas.ExplicitMemory,
  },
  UpdatePipelineEntries: {
    call: schemas.UpdatePipelineEntries,
    response: schemas.UpdatePipelineEntriesResponse,
  },
  UpdateRoutine: { call: schemas.UpdateRoutine, response: schemas.RoutineInfo },
  UpdateSharing: {
    call: schemas.UpdateSharing,
    response: schemas.UpdateSharingResponse,
  },
  UpdateThreadLabels: {
    call: schemas.UpdateThreadLabels,
    response: schemas.UpdateThreadLabelsResponse,
  },
  UploadFile: {
    call: schemas.UploadFile,
    response: schemas.UploadFileResponse,
  },
  WebFetch: { call: schemas.WebFetch, response: schemas.WebFetchResponse },
  WebSearch: { call: schemas.WebSearch, response: schemas.WebSearchResponse },
};

export type ToolName = keyof ToolParserMap;

type NamedRawTool = {
  id: string;
  name: string;
  json: unknown;
};

type ToolDataMap = {
  AddSharedCalendarEvent: {
    call: types.AddSharedCalendarEvent;
    response: types.ToolCalendarEvent;
  };
  AddToPipeline: {
    call: types.AddToPipeline;
    response: types.AddToPipelineResponse;
  };
  ApplyCanvasEdits: {
    call: types.ApplyCanvasEdits;
    response: types.CanvasResponse;
  };
  BashCodeExecution: {
    call: types.BashCodeExecution;
    response: types.BashCodeExecutionResponse;
  };
  BulkSetEntityPropertyOptions: {
    call: types.BulkSetEntityPropertyOptions;
    response: types.BulkSetEntityPropertyOptionsResponse;
  };
  CalculateSpreadsheet: {
    call: types.CalculateSpreadsheet;
    response: types.SpreadsheetResponse;
  };
  ChangeBooking: { call: types.ChangeBooking; response: types.Booking };
  Comment: { call: types.Comment; response: types.CommentResponse };
  CommentOnText: {
    call: types.CommentOnText;
    response: types.CommentOnTextResponse;
  };
  ConfigureAgent: {
    call: types.ConfigureAgent;
    response: types.ConfigureAgentResponse;
  };
  ConfigureBot: {
    call: types.ConfigureBot;
    response: types.ConfigureBotResponse;
  };
  ConnectMcpServer: {
    call: types.ConnectMcpServer;
    response: types.ConnectMcpServerResponse;
  };
  ContentSearch: {
    call: types.ContentSearch;
    response: types.SearchToolResponse;
  };
  CreateAgentSession: {
    call: types.CreateAgentSession;
    response: types.DispatchedCodingAgent;
  };
  CreateBookingLink: {
    call: types.CreateBookingLink;
    response: types.BookingLinkResult;
  };
  CreateBot: { call: types.CreateBot; response: types.CreateBotResponse };
  CreateCalendarEvent: {
    call: types.CreateCalendarEvent;
    response: types.UserToolResponseForToolCalendarEvent;
  };
  CreateChannel: {
    call: types.CreateChannel;
    response: types.CreateChannelResponse;
  };
  CreateCompany: {
    call: types.CreateCompany;
    response: types.CreateCompanyResponse;
  };
  CreateConfirmedCalendarEvent: {
    call: types.CreateConfirmedCalendarEvent;
    response: types.ToolCalendarEvent;
  };
  CreateContact: {
    call: types.CreateContact;
    response: types.CreateContactResponse;
  };
  CreateDocument: {
    call: types.CreateDocument;
    response: types.CreateDocumentResponse;
  };
  CreateForm: { call: types.CreateForm; response: types.MutationResult };
  CreateImportEntity: {
    call: types.CreateImportEntity;
    response: types.CreateImportEntityResponse;
  };
  CreateInitiative: {
    call: types.CreateInitiative;
    response: types.ProjectDetails;
  };
  CreatePipeline: {
    call: types.CreatePipeline;
    response: types.CreatePipelineResponse;
  };
  CreateProject: {
    call: types.CreateProject;
    response: types.CreateProjectResponse;
  };
  CreateRoutine: { call: types.CreateRoutine; response: types.RoutineInfo };
  CreateSkill: { call: types.CreateSkill; response: types.CreateSkillResponse };
  CreateTag: { call: types.CreateTag; response: types.CreateTagResponse };
  Decide: { call: types.Decide; response: types.DecisionResponse };
  DeleteBot: { call: types.DeleteBot; response: types.DeleteBotResponse };
  DeleteCalendarEvent: {
    call: types.DeleteCalendarEvent;
    response: types.DeleteCalendarEventResponse;
  };
  DeleteCallRecord: {
    call: types.DeleteCallRecord;
    response: types.DeleteCallRecordResponse;
  };
  DeleteChannelMessage: {
    call: types.DeleteChannelMessage;
    response: types.DeleteChannelMessageResponse;
  };
  DeleteComment: {
    call: types.DeleteComment;
    response: types.DeleteCommentResponse;
  };
  DeleteDatabaseView: {
    call: types.DeleteDatabaseView;
    response: types.DeletedDatabaseView;
  };
  DeleteImportEntity: {
    call: types.DeleteImportEntity;
    response: types.DeleteImportEntityResponse;
  };
  DeleteInitiative: {
    call: types.DeleteInitiative;
    response: types.ProjectOperationComplete;
  };
  DeleteRoutine: { call: types.DeleteRoutine; response: types.DeletedRoutine };
  DeleteTag: { call: types.DeleteTag; response: types.DeleteTagResponse };
  DescribeCodeTools: {
    call: types.DescribeCodeTools;
    response: types.CodeToolsDescription;
  };
  DescribeDatabase: {
    call: types.DescribeDatabase;
    response: types.ToolDatabaseSchema;
  };
  DiscoverConnectors: {
    call: types.DiscoverConnectors;
    response: types.DiscoverConnectorsResponse;
  };
  DispatchCodingAgent: {
    call: types.DispatchCodingAgent;
    response: types.DispatchedCodingAgent;
  };
  DuplicateItem: {
    call: types.DuplicateItem;
    response: types.DuplicateItemResponse;
  };
  EditBookingLink: {
    call: types.EditBookingLink;
    response: types.BookingLinkResult;
  };
  EditCanvas: { call: types.EditCanvas; response: types.CanvasResponse };
  EditChannelMessage: {
    call: types.EditChannelMessage;
    response: types.EditChannelMessageResponse;
  };
  EditComment: { call: types.EditComment; response: types.EditCommentResponse };
  EditDocument: {
    call: types.EditDocument;
    response: types.EditDocumentResponse;
  };
  EditForm: { call: types.EditForm; response: types.MutationResult };
  EditPipeline: {
    call: types.EditPipeline;
    response: types.EditPipelineResponse;
  };
  EditPresentation: {
    call: types.EditPresentation;
    response: types.PresentationEditOutcome;
  };
  EditSpreadsheet: {
    call: types.EditSpreadsheet;
    response: types.SpreadsheetResponse;
  };
  EditTag: { call: types.EditTag; response: types.EditTagResponse };
  EditWordDocument: {
    call: types.EditWordDocument;
    response: types.WordDocumentResponse;
  };
  ExecuteCode: { call: types.ExecuteCode; response: types.ExecutionReceipt };
  ExportPipelineCsv: {
    call: types.ExportPipelineCsv;
    response: types.ExportPipelineCsvResponse;
  };
  FindPipelineEntries: {
    call: types.FindPipelineEntries;
    response: types.FindPipelineEntriesResponse;
  };
  GenerateImage: {
    call: types.GenerateImage;
    response: types.GenerateImageResponse;
  };
  GenerateObject: {
    call: types.GenerateObject;
    response: types.GenerateObjectResponse;
  };
  GetBookingInsights: {
    call: types.GetBookingInsights;
    response: types.BookingInsights;
  };
  GetBookingRescheduleSlots: {
    call: types.GetBookingRescheduleSlots;
    response: types.BookingSlotsResult;
  };
  GetBotWebhooks: {
    call: types.GetBotWebhooks;
    response: types.GetBotWebhooksResponse;
  };
  GetCompany: { call: types.GetCompany; response: types.GetCompanyResponse };
  GetEntityProperties: {
    call: types.GetEntityProperties;
    response: types.GetEntityPropertiesResponse;
  };
  GetTeamAvailability: {
    call: types.GetTeamAvailability;
    response: types.TeamAvailability;
  };
  GetThread: { call: types.GetThread; response: types.GetThreadResponse };
  GetUserActivity: {
    call: types.GetUserActivity;
    response: types.ActivityReports;
  };
  ImportCompaniesCsv: {
    call: types.ImportCompaniesCsv;
    response: types.ImportCompaniesCsvResponse;
  };
  ImportFromJira: {
    call: types.ImportFromJira;
    response: types.TrackerImportResponse;
  };
  ImportFromLinear: {
    call: types.ImportFromLinear;
    response: types.TrackerImportResponse;
  };
  ImportFromNotion: {
    call: types.ImportFromNotion;
    response: types.ImportFromNotionResponse;
  };
  ImportNotionPage: {
    call: types.ImportNotionPage;
    response: types.ImportNotionPageResponse;
  };
  ImportPipelineCsv: {
    call: types.ImportPipelineCsv;
    response: types.ImportPipelineCsvResponse;
  };
  IssueBotCredential: {
    call: types.IssueBotCredential;
    response: types.IssueBotCredentialResponse;
  };
  ListAgents: { call: types.ListAgents; response: types.ListAgentsResponse };
  ListAgentUpdates: {
    call: types.ListAgentUpdates;
    response: types.AgentUpdates;
  };
  ListBookingLinks: {
    call: types.ListBookingLinks;
    response: types.ListBookingLinksResult;
  };
  ListBookings: { call: types.ListBookings; response: types.BookingsResult };
  ListBots: { call: types.ListBots; response: types.ListBotsResponse };
  ListCalendarEvents: {
    call: types.ListCalendarEvents;
    response: types.ListCalendarEventsResponse;
  };
  ListCalendars: {
    call: types.ListCalendars;
    response: types.ListCalendarsToolResponse;
  };
  ListCodingAgents: {
    call: types.ListCodingAgents;
    response: types.ListCodingAgentsResponse;
  };
  ListCompanies: {
    call: types.ListCompanies;
    response: types.ListCompaniesResponse;
  };
  ListDatabases: {
    call: types.ListDatabases;
    response: types.ListDatabasesResponse;
  };
  ListEntities: {
    call: types.ListEntities;
    response: types.ListEntitiesResponse;
  };
  ListForms: { call: types.ListForms; response: types.ListResult };
  ListImportEntities: {
    call: types.ListImportEntities;
    response: types.ListImportEntitiesResponse;
  };
  ListInboxes: { call: types.ListInboxes; response: types.ListInboxesResponse };
  ListInitiatives: {
    call: types.ListInitiatives;
    response: types.ProjectListResult;
  };
  ListLabels: { call: types.ListLabels; response: types.ListLabelsResponse };
  ListNotifications: {
    call: types.ListNotifications;
    response: types.ListNotificationsResponse;
  };
  ListPipelines: {
    call: types.ListPipelines;
    response: types.ListPipelinesResponse;
  };
  ListRoutines: { call: types.ListRoutines; response: types.RoutineList };
  ListSkills: { call: types.ListSkills; response: types.ListSkillsResponse };
  ListTags: { call: types.ListTags; response: types.ListTagsResponse };
  ListTeamMembers: {
    call: types.ListTeamMembers;
    response: types.ListTeamMembersResponse;
  };
  LoadTools: { call: types.LoadTools; response: types.LoadToolsResponse };
  ManageAgentSession: {
    call: types.ManageAgentSession;
    response: types.SessionActionResult;
  };
  ManageBotChannelAccess: {
    call: types.ManageBotChannelAccess;
    response: types.ManageBotChannelAccessResponse;
  };
  ManageChannelParticipants: {
    call: types.ManageChannelParticipants;
    response: types.ManageChannelParticipantsResponse;
  };
  MarkNotificationsDone: {
    call: types.MarkNotificationsDone;
    response: types.MarkNotificationsResponse;
  };
  MarkNotificationsSeen: {
    call: types.MarkNotificationsSeen;
    response: types.MarkNotificationsResponse;
  };
  MoveToProject: {
    call: types.MoveToProject;
    response: types.MoveToProjectResponse;
  };
  MoveToTrash: { call: types.MoveToTrash; response: types.MoveToTrashResponse };
  MuteNotifications: {
    call: types.MuteNotifications;
    response: types.MuteNotificationsResponse;
  };
  NameSearch: { call: types.NameSearch; response: types.SearchToolResponse };
  OpenDirectMessage: {
    call: types.OpenDirectMessage;
    response: types.OpenDirectMessageResponse;
  };
  QueryDatabase: {
    call: types.QueryDatabase;
    response: types.QueryDatabaseResponse;
  };
  ReactToChannelMessage: {
    call: types.ReactToChannelMessage;
    response: types.ReactToChannelMessageResponse;
  };
  ReadActivity: {
    call: types.ReadActivity;
    response: types.ReadActivityResponse;
  };
  ReadAgentSession: {
    call: types.ReadAgentSession;
    response: types.SessionConversation;
  };
  ReadAgentSessionSharing: {
    call: types.ReadAgentSessionSharing;
    response: types.SessionSharingResponse;
  };
  ReadBookingSettings: {
    call: types.ReadBookingSettings;
    response: types.BookingSettingsResult;
  };
  ReadCalendarEvent: {
    call: types.ReadCalendarEvent;
    response: types.ReadCalendarEventResponse;
  };
  ReadCallRecord: {
    call: types.ReadCallRecord;
    response: types.ReadCallRecordResponse;
  };
  ReadCanvas: { call: types.ReadCanvas; response: types.CanvasResponse };
  ReadChannelMessageContext: {
    call: types.ReadChannelMessageContext;
    response: types.ReadChannelMessageContextResponse;
  };
  ReadChannelMessages: {
    call: types.ReadChannelMessages;
    response: types.ReadChannelMessagesResponse;
  };
  ReadChannelThread: {
    call: types.ReadChannelThread;
    response: types.ReadChannelThreadResponse;
  };
  ReadChat: { call: types.ReadChat; response: types.ReadChatResponse };
  ReadCodeDocs: { call: types.ReadCodeDocs; response: types.SymbolReferences };
  ReadContent: { call: types.ReadContent; response: types.ReadContentResponse };
  ReadDesign: { call: types.ReadDesign; response: types.ReadDesignResponse };
  ReadDiscussion: {
    call: types.ReadDiscussion;
    response: types.ReadDiscussionResponse;
  };
  ReadForm: { call: types.ReadForm; response: types.ReadResult };
  ReadIllustratorDocument: {
    call: types.ReadIllustratorDocument;
    response: types.ReadIllustratorDocumentResponse;
  };
  ReadInitiative: {
    call: types.ReadInitiative;
    response: types.ProjectReadResult;
  };
  ReadInitiativeActivity: {
    call: types.ReadInitiativeActivity;
    response: types.ProjectActivityResult;
  };
  ReadMemory: { call: types.ReadMemory; response: types.ExplicitMemory };
  ReadMetadata: {
    call: types.ReadMetadata;
    response: types.ReadMetadataResponse;
  };
  ReadPhotoshopDocument: {
    call: types.ReadPhotoshopDocument;
    response: types.ReadPhotoshopDocumentResponse;
  };
  ReadPresentation: {
    call: types.ReadPresentation;
    response: types.ReadPresentationResponse;
  };
  ReadProject: { call: types.ReadProject; response: types.ReadProjectResponse };
  ReadRoutine: { call: types.ReadRoutine; response: types.RoutineDetails };
  ReadSkill: { call: types.ReadSkill; response: types.ReadSkillResponse };
  ReadSpreadsheet: {
    call: types.ReadSpreadsheet;
    response: types.SpreadsheetResponse;
  };
  ReadThread: { call: types.ReadThread; response: types.ReadResponse };
  ReadWordDocument: {
    call: types.ReadWordDocument;
    response: types.WordDocumentResponse;
  };
  RemoveFromPipeline: {
    call: types.RemoveFromPipeline;
    response: types.RemoveFromPipelineResponse;
  };
  RenameChannel: {
    call: types.RenameChannel;
    response: types.RenameChannelResponse;
  };
  RenameDocument: {
    call: types.RenameDocument;
    response: types.RenameDocumentResponse;
  };
  RenameItem: { call: types.RenameItem; response: types.RenameItemResponse };
  RenderCanvas: { call: types.RenderCanvas; response: types.CanvasRender };
  ResolveComment: {
    call: types.ResolveComment;
    response: types.ResolveCommentResponse;
  };
  RunRoutine: { call: types.RunRoutine; response: types.RoutineRunStarted };
  SaveDatabaseQuery: {
    call: types.SaveDatabaseQuery;
    response: types.SaveDatabaseQueryResponse;
  };
  SaveDatabaseView: {
    call: types.SaveDatabaseView;
    response: types.SavedDatabaseView;
  };
  SearchSkills: {
    call: types.SearchSkills;
    response: types.SearchSkillsResponse;
  };
  SearchTools: { call: types.SearchTools; response: types.SearchToolsResponse };
  SelfKnowledge: {
    call: types.SelfKnowledge;
    response: types.SelfKnowledgeResponse;
  };
  SendChannelMessage: {
    call: types.SendChannelMessage;
    response: types.SendChannelMessageResponse;
  };
  SendConfirmedEmail: {
    call: types.SendConfirmedEmail;
    response: types.SendEmailResponse;
  };
  SendEmail: {
    call: types.SendEmail;
    response: types.UserToolResponseForSendEmailResponse;
  };
  SetEntityProperty: {
    call: types.SetEntityProperty;
    response: types.SetEntityPropertyResponse;
  };
  SetFavorite: { call: types.SetFavorite; response: types.SetFavoriteResponse };
  SetFormAccess: { call: types.SetFormAccess; response: types.MutationResult };
  SetSenderPolicy: {
    call: types.SetSenderPolicy;
    response: types.SetSenderPolicyResponse;
  };
  ShareWithChannel: {
    call: types.ShareWithChannel;
    response: types.ShareWithChannelResponse;
  };
  Subagent: { call: types.Subagent; response: types.SubagentResponse };
  TextEditorCodeExecution: {
    call: types.TextEditorCodeExecution;
    response: types.TextEditorCodeExecutionResponse;
  };
  UpdateAgentSessionSharing: {
    call: types.UpdateAgentSessionSharing;
    response: types.SessionSharingResponse;
  };
  UpdateBookingSettings: {
    call: types.UpdateBookingSettings;
    response: types.BookingSettingsResult;
  };
  UpdateCalendarEvent: {
    call: types.UpdateCalendarEvent;
    response: types.ToolCalendarEvent;
  };
  UpdateCallRecord: {
    call: types.UpdateCallRecord;
    response: types.UpdateCallRecordResponse;
  };
  UpdateInitiative: {
    call: types.UpdateInitiative;
    response: types.ProjectDetails;
  };
  UpdateInitiativeSharing: {
    call: types.UpdateInitiativeSharing;
    response: types.ProjectDetails;
  };
  UpdateMemory: { call: types.UpdateMemory; response: types.ExplicitMemory };
  UpdatePipelineEntries: {
    call: types.UpdatePipelineEntries;
    response: types.UpdatePipelineEntriesResponse;
  };
  UpdateRoutine: { call: types.UpdateRoutine; response: types.RoutineInfo };
  UpdateSharing: {
    call: types.UpdateSharing;
    response: types.UpdateSharingResponse;
  };
  UpdateThreadLabels: {
    call: types.UpdateThreadLabels;
    response: types.UpdateThreadLabelsResponse;
  };
  UploadFile: { call: types.UploadFile; response: types.UploadFileResponse };
  WebFetch: { call: types.WebFetch; response: types.WebFetchResponse };
  WebSearch: { call: types.WebSearch; response: types.WebSearchResponse };
};

export type NamedTool<
  TName extends ToolName = ToolName,
  TDirection extends 'call' | 'response' = 'call' | 'response',
> = {
  id: string;
  name: TName;
  data: ToolDataMap[TName][TDirection];
};

function deserializeTool<T extends NamedTool>(
  tool: NamedRawTool,
  direction: 'call' | 'response'
): Result<T, ResultError<'parse_error' | 'not_found'>[]> {
  if (!(tool.name in toolParserMap)) {
    return err([
      { code: 'not_found', message: `tool name not found ${tool.name}` },
    ]);
  }
  const parser = toolParserMap[tool.name as ToolName];
  const maybeToolCall = parser[direction].safeParse(
    bookingLinkHistory(tool.name, direction, tool.json)
  );
  if (maybeToolCall.success) {
    return ok({
      id: tool.id,
      name: tool.name as ToolName,
      data: maybeToolCall.data,
    } as T);
  }
  return err([{ code: 'parse_error', message: 'tool parsing failed' }]);
}

export function deserializeToolCall(
  tool: NamedRawTool
): Result<
  NamedTool<ToolName, 'call'>,
  ResultError<'parse_error' | 'not_found'>[]
> {
  return deserializeTool(tool, 'call');
}

export function deserializeToolResponse(
  tool: NamedRawTool
): Result<
  NamedTool<ToolName, 'response'>,
  ResultError<'parse_error' | 'not_found'>[]
> {
  return deserializeTool(tool, 'response');
}