Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(mistral-ai): add AI actions and output schemas (#15762)

Kishan Parmared6f2de65723
diff --git a/bun.lock b/bun.lock
index 941863274f0..6a5ddf09181 100644
--- a/bun.lock
+++ b/bun.lock
@@ -5999,7 +5999,7 @@
},
"packages/pieces/community/mistral-ai": {
"name": "@activepieces/piece-mistral-ai",
- "version": "0.3.0",
+ "version": "0.4.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/mistral-ai/package.json b/packages/pieces/community/mistral-ai/package.json
index 7a9729bbae4..dece296a798 100644
--- a/packages/pieces/community/mistral-ai/package.json
+++ b/packages/pieces/community/mistral-ai/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-mistral-ai",
- "version": "0.3.0",
+ "version": "0.4.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/mistral-ai/src/index.ts b/packages/pieces/community/mistral-ai/src/index.ts
index 3c59769bab7..0f62d924531 100644
--- a/packages/pieces/community/mistral-ai/src/index.ts
+++ b/packages/pieces/community/mistral-ai/src/index.ts
@@ -5,6 +5,48 @@ import { createEmbeddings } from "./lib/actions/create-embeddings";
import { uploadFile } from "./lib/actions/upload-file";
import { runOcr } from "./lib/actions/run-ocr";
import { listModels } from "./lib/actions/list-models";
+import { generateChatCompletion } from "./lib/actions/generate-chat-completion";
+import { completeCodeFim } from "./lib/actions/complete-code-fim";
+import { transcribeAudio } from "./lib/actions/transcribe-audio";
+import { generateSpeech } from "./lib/actions/generate-speech";
+import { moderateText } from "./lib/actions/moderate-text";
+import { moderateChat } from "./lib/actions/moderate-chat";
+import { getModel } from "./lib/actions/get-model";
+import { listFiles } from "./lib/actions/list-files";
+import { getFile } from "./lib/actions/get-file";
+import { deleteFile } from "./lib/actions/delete-file";
+import { getFileSignedUrl } from "./lib/actions/get-file-signed-url";
+import { downloadFile } from "./lib/actions/download-file";
+import { createAgent } from "./lib/actions/create-agent";
+import { listAgents } from "./lib/actions/list-agents";
+import { getAgent } from "./lib/actions/get-agent";
+import { updateAgent } from "./lib/actions/update-agent";
+import { deleteAgent } from "./lib/actions/delete-agent";
+import { startConversation } from "./lib/actions/start-conversation";
+import { appendToConversation } from "./lib/actions/append-to-conversation";
+import { restartConversation } from "./lib/actions/restart-conversation";
+import { listConversations } from "./lib/actions/list-conversations";
+import { getConversation } from "./lib/actions/get-conversation";
+import { getConversationHistory } from "./lib/actions/get-conversation-history";
+import { getConversationMessages } from "./lib/actions/get-conversation-messages";
+import { deleteConversation } from "./lib/actions/delete-conversation";
+import { createLibrary } from "./lib/actions/create-library";
+import { listLibraries } from "./lib/actions/list-libraries";
+import { getLibrary } from "./lib/actions/get-library";
+import { updateLibrary } from "./lib/actions/update-library";
+import { deleteLibrary } from "./lib/actions/delete-library";
+import { uploadLibraryDocument } from "./lib/actions/upload-library-document";
+import { listLibraryDocuments } from "./lib/actions/list-library-documents";
+import { getLibraryDocument } from "./lib/actions/get-library-document";
+import { updateLibraryDocument } from "./lib/actions/update-library-document";
+import { deleteLibraryDocument } from "./lib/actions/delete-library-document";
+import { getDocumentStatus } from "./lib/actions/get-document-status";
+import { getDocumentTextContent } from "./lib/actions/get-document-text-content";
+import { reprocessDocument } from "./lib/actions/reprocess-document";
+import { listBatchJobs } from "./lib/actions/list-batch-jobs";
+import { createBatchJob } from "./lib/actions/create-batch-job";
+import { getBatchJob } from "./lib/actions/get-batch-job";
+import { cancelBatchJob } from "./lib/actions/cancel-batch-job";
import { mistralAuth } from "./lib/common/auth";
import { mistralRequest } from "./lib/common/request";
import { createCustomApiCallAction } from "@activepieces/pieces-common";
@@ -13,7 +55,7 @@ export const mistralAi = createPiece({
displayName: "Mistral AI",
description: "Mistral AI provides state-of-the-art open-weight and hosted language models for text generation, embeddings, and reasoning tasks.",
auth: mistralAuth,
- minimumSupportedRelease: "0.36.1",
+ minimumSupportedRelease: "0.87.0",
logoUrl: "https://cdn.activepieces.com/pieces/mistral-ai.png",
authors: ["sparkybug"],
categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],
@@ -23,6 +65,48 @@ export const mistralAi = createPiece({
uploadFile,
runOcr,
listModels,
+ generateChatCompletion,
+ completeCodeFim,
+ transcribeAudio,
+ generateSpeech,
+ moderateText,
+ moderateChat,
+ getModel,
+ listFiles,
+ getFile,
+ deleteFile,
+ getFileSignedUrl,
+ downloadFile,
+ createAgent,
+ listAgents,
+ getAgent,
+ updateAgent,
+ deleteAgent,
+ startConversation,
+ appendToConversation,
+ restartConversation,
+ listConversations,
+ getConversation,
+ getConversationHistory,
+ getConversationMessages,
+ deleteConversation,
+ createLibrary,
+ listLibraries,
+ getLibrary,
+ updateLibrary,
+ deleteLibrary,
+ uploadLibraryDocument,
+ listLibraryDocuments,
+ getLibraryDocument,
+ updateLibraryDocument,
+ deleteLibraryDocument,
+ getDocumentStatus,
+ getDocumentTextContent,
+ reprocessDocument,
+ listBatchJobs,
+ createBatchJob,
+ getBatchJob,
+ cancelBatchJob,
createCustomApiCallAction({
auth: mistralAuth,
baseUrl: (auth) => (auth ? mistralRequest.getConfig(auth).baseUrl : 'https://api.mistral.ai/v1'),
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/append-to-conversation.ts b/packages/pieces/community/mistral-ai/src/lib/actions/append-to-conversation.ts
new file mode 100644
index 00000000000..44894ac3e94
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/append-to-conversation.ts
@@ -0,0 +1,40 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { conversationUtils, ConversationResponse } from '../common/conversations';
+import { conversationReplyOutputSchema } from '../output-schemas';
+
+export const appendToConversation = createAction({
+ auth: mistralAuth,
+ name: 'append_to_conversation',
+ classification: 'WRITE',
+ displayName: 'Append to Conversation',
+ description: 'Send a follow-up message in an existing conversation (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Sends a follow-up user message to an existing stored conversation (Beta) and returns the new reply and output entries; Mistral keeps the earlier turns, so only send the new message. Needs a conversation id from Start Conversation or List Conversations. Use Restart Conversation to branch from an earlier entry instead. Not idempotent: each call adds a turn and bills a new reply.',
+ idempotent: false,
+ },
+ outputSchema: conversationReplyOutputSchema,
+ props: {
+ conversation_id: conversationUtils.conversationIdProp(),
+ message: Property.LongText({
+ displayName: 'Message',
+ description: 'The next user message.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { conversation_id, message } = context.propsValue;
+ const response = await mistralApi.call<ConversationResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/conversations/${encodeURIComponent(conversation_id)}`,
+ body: { inputs: message, stream: false, store: true },
+ timeout: 300000,
+ });
+ return conversationUtils.formatResponse(response);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/cancel-batch-job.ts b/packages/pieces/community/mistral-ai/src/lib/actions/cancel-batch-job.ts
new file mode 100644
index 00000000000..1b80526ad3b
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/cancel-batch-job.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { batchUtils, MistralBatchJob } from '../common/batch';
+import { batchJobOutputSchema } from '../output-schemas';
+
+export const cancelBatchJob = createAction({
+ auth: mistralAuth,
+ name: 'cancel_batch_job',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Cancel Batch Job',
+ description: 'Stop a queued or running batch job.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Requests cancellation of a queued or running batch job and returns its updated status (usually CANCELLATION_REQUESTED, then CANCELLED); requests already completed stay billed and their results are kept. Get the job id from List Batch Jobs. Cancelling an already-cancelled job leaves it cancelled, so a retry is harmless.',
+ idempotent: true,
+ },
+ outputSchema: batchJobOutputSchema,
+ props: {
+ job_id: batchUtils.jobIdProp(),
+ },
+ async run(context) {
+ const job = await mistralApi.call<MistralBatchJob>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/batch/jobs/${encodeURIComponent(context.propsValue.job_id)}/cancel`,
+ });
+ return batchUtils.formatJob(job);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/complete-code-fim.ts b/packages/pieces/community/mistral-ai/src/lib/actions/complete-code-fim.ts
new file mode 100644
index 00000000000..bc4e53aa703
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/complete-code-fim.ts
@@ -0,0 +1,80 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { completeCodeFimOutputSchema } from '../output-schemas';
+
+export const completeCodeFim = createAction({
+ auth: mistralAuth,
+ name: 'complete_code_fim',
+ classification: 'READ',
+ displayName: 'Complete Code (Fill-in-the-Middle)',
+ description: 'Generate the code that belongs between a prefix and an optional suffix with a Codestral model.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Fills in code between a prefix (prompt) and an optional suffix using a Codestral fill-in-the-middle model, returning only the generated middle text. Pick this for code insertion or completion inside an existing file; use Generate Chat Completion for explaining or writing code from an instruction. Only Codestral models support this endpoint. Not idempotent: each call bills a new completion.',
+ idempotent: false,
+ },
+ outputSchema: completeCodeFimOutputSchema,
+ props: {
+ model: Property.ShortText({
+ displayName: 'Model',
+ description: 'A Codestral model id. Fill-in-the-middle only works with Codestral models.',
+ required: true,
+ defaultValue: 'codestral-latest',
+ }),
+ prompt: Property.LongText({
+ displayName: 'Code Before (Prompt)',
+ description: 'The code that comes before the part to generate.',
+ required: true,
+ }),
+ suffix: Property.LongText({
+ displayName: 'Code After (Suffix)',
+ description: 'Optional code that comes after the part to generate.',
+ required: false,
+ }),
+ max_tokens: Property.Number({ displayName: 'Max Tokens', required: false }),
+ temperature: Property.Number({ displayName: 'Temperature', required: false }),
+ stop: Property.Array({
+ displayName: 'Stop Sequences',
+ description: 'Stop generating when any of these strings is produced.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { model, prompt, suffix, max_tokens, temperature, stop } = context.propsValue;
+ const stopSequences = mistralApi.toStringArray(stop);
+ const response = await mistralApi.call<FimResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/fim/completions',
+ body: mistralApi.compact({
+ model,
+ prompt,
+ suffix,
+ max_tokens,
+ temperature,
+ stop: stopSequences.length > 0 ? stopSequences : undefined,
+ }),
+ timeout: 120000,
+ });
+ const choice = response.choices[0];
+ return {
+ id: response.id,
+ model: response.model,
+ completion: mistralApi.contentToText(choice?.message?.content),
+ finish_reason: choice?.finish_reason ?? null,
+ prompt_tokens: response.usage?.prompt_tokens ?? null,
+ completion_tokens: response.usage?.completion_tokens ?? null,
+ total_tokens: response.usage?.total_tokens ?? null,
+ };
+ },
+});
+
+type FimResponse = {
+ id: string;
+ model: string;
+ choices: { finish_reason: string; message?: { content: unknown } }[];
+ usage?: { prompt_tokens: number; completion_tokens: number; total_tokens: number };
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/create-agent.ts b/packages/pieces/community/mistral-ai/src/lib/actions/create-agent.ts
new file mode 100644
index 00000000000..73412c8cd38
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/create-agent.ts
@@ -0,0 +1,58 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { agentUtils, MistralAgent } from '../common/agents';
+import { agentOutputSchema } from '../output-schemas';
+
+export const createAgent = createAction({
+ auth: mistralAuth,
+ name: 'create_agent',
+ classification: 'WRITE',
+ displayName: 'Create Agent',
+ description: 'Create a Mistral agent with a model, instructions and tools (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates a reusable Mistral agent (Beta) from a model, a name, optional instructions, built-in tools (web search, code interpreter, image generation) and document libraries, and returns its agent id. Run the agent with Start Conversation using that id; change it later with Update Agent. Not idempotent: each call creates another agent, even with the same name.',
+ idempotent: false,
+ },
+ outputSchema: agentOutputSchema,
+ props: {
+ name: Property.ShortText({ displayName: 'Name', required: true }),
+ model: Property.ShortText({
+ displayName: 'Model',
+ description: 'Chat model id the agent runs on, e.g. mistral-medium-latest.',
+ required: true,
+ defaultValue: 'mistral-medium-latest',
+ }),
+ instructions: Property.LongText({
+ displayName: 'Instructions',
+ description: 'The system prompt the agent follows in every conversation.',
+ required: false,
+ }),
+ description: Property.ShortText({ displayName: 'Description', required: false }),
+ ...agentUtils.toolsProps(),
+ temperature: Property.Number({ displayName: 'Temperature', required: false }),
+ },
+ async run(context) {
+ const { name, model, instructions, description, built_in_tools, library_ids, temperature } = context.propsValue;
+ const agent = await mistralApi.call<MistralAgent>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/agents',
+ body: mistralApi.compact({
+ name,
+ model,
+ instructions,
+ description,
+ tools: agentUtils.buildTools({
+ builtInTools: mistralApi.toStringArray(built_in_tools),
+ libraryIds: mistralApi.toStringArray(library_ids),
+ }),
+ completion_args: temperature === undefined || temperature === null ? undefined : { temperature },
+ }),
+ });
+ return agentUtils.formatAgent(agent);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/create-batch-job.ts b/packages/pieces/community/mistral-ai/src/lib/actions/create-batch-job.ts
new file mode 100644
index 00000000000..84d20028c40
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/create-batch-job.ts
@@ -0,0 +1,76 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { BATCH_ENDPOINT_OPTIONS, batchUtils, MistralBatchJob } from '../common/batch';
+import { batchJobOutputSchema } from '../output-schemas';
+
+export const createBatchJob = createAction({
+ auth: mistralAuth,
+ name: 'create_batch_job',
+ classification: 'WRITE',
+ displayName: 'Create Batch Job',
+ description: 'Start a batch inference job over many requests.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Starts an asynchronous batch inference job that runs many requests against one endpoint and model at reduced cost, and returns the job id and initial status (not the results). Give either uploaded .jsonl input file ids (Upload File with purpose batch) or inline requests. Poll Get Batch Job until the status is SUCCESS, then fetch the output file with Download File. Not idempotent: each call starts and bills a new job.',
+ idempotent: false,
+ },
+ outputSchema: batchJobOutputSchema,
+ props: {
+ endpoint: Property.StaticDropdown({
+ displayName: 'Endpoint',
+ required: true,
+ defaultValue: '/v1/chat/completions',
+ options: { options: BATCH_ENDPOINT_OPTIONS },
+ }),
+ model: Property.ShortText({
+ displayName: 'Model',
+ description: 'Model id to run every request with, e.g. mistral-small-latest.',
+ required: false,
+ }),
+ input_files: Property.Array({
+ displayName: 'Input File IDs',
+ description: 'UUIDs of .jsonl files uploaded with purpose batch. Each line needs a custom_id and a body.',
+ required: false,
+ }),
+ requests: Property.Json({
+ displayName: 'Inline Requests',
+ description: 'Instead of files, a JSON array of requests, each {"custom_id": "...", "body": {...}}.',
+ required: false,
+ }),
+ metadata: Property.Json({
+ displayName: 'Metadata',
+ description: 'Optional JSON object stored with the job.',
+ required: false,
+ }),
+ timeout_hours: Property.Number({
+ displayName: 'Timeout (hours)',
+ required: false,
+ defaultValue: 24,
+ }),
+ },
+ async run(context) {
+ const { endpoint, model, input_files, requests, metadata, timeout_hours } = context.propsValue;
+ const inputFiles = mistralApi.toStringArray(input_files);
+ const inlineRequests = mistralApi.parseJsonInput({ value: requests, fieldName: 'Inline Requests' });
+ if (inputFiles.length === 0 && (!Array.isArray(inlineRequests) || inlineRequests.length === 0)) {
+ throw new Error('Provide Input File IDs or a non-empty Inline Requests array.');
+ }
+ const job = await mistralApi.call<MistralBatchJob>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/batch/jobs',
+ body: mistralApi.compact({
+ endpoint,
+ model,
+ input_files: inputFiles.length > 0 ? inputFiles : undefined,
+ requests: Array.isArray(inlineRequests) && inlineRequests.length > 0 ? inlineRequests : undefined,
+ metadata: mistralApi.parseJsonInput({ value: metadata, fieldName: 'Metadata' }),
+ timeout_hours,
+ }),
+ });
+ return batchUtils.formatJob(job);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/create-chat-completion.ts b/packages/pieces/community/mistral-ai/src/lib/actions/create-chat-completion.ts
index 09708ff88f1..2d55d57dd40 100644
--- a/packages/pieces/community/mistral-ai/src/lib/actions/create-chat-completion.ts
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/create-chat-completion.ts
@@ -5,7 +5,7 @@ import { modelDropdown, parseMistralError } from '../common/props';
import { mistralRequest } from '../common/request';
export const createChatCompletion = createAction({
- audience: 'both',
+ audience: 'human',
auth: mistralAuth,
name: 'create_chat_completion',
classification: 'READ',
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/create-embeddings.ts b/packages/pieces/community/mistral-ai/src/lib/actions/create-embeddings.ts
index bd32d321658..68327ba622e 100644
--- a/packages/pieces/community/mistral-ai/src/lib/actions/create-embeddings.ts
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/create-embeddings.ts
@@ -3,6 +3,7 @@ import { HttpMethod, httpClient } from '@activepieces/pieces-common';
import { mistralAuth } from '../common/auth';
import { parseMistralError } from '../common/props';
import { mistralRequest } from '../common/request';
+import { createEmbeddingsOutputSchema } from '../output-schemas';
export const createEmbeddings = createAction({
audience: 'both',
@@ -12,6 +13,7 @@ export const createEmbeddings = createAction({
displayName: 'Create Embeddings',
description: 'Creates new embedding in Mistral AI.',
aiMetadata: { description: 'Converts an array of text strings into numeric embedding vectors using Mistral\'s fixed mistral-embed model; the model is not selectable here, unlike the sibling Ask Mistral action, and a whole batch of strings is embedded in one call. Use it for semantic search, similarity, or clustering pipelines, and pick Ask Mistral when you need generated prose rather than numbers. Requires a non-empty array of input strings; idempotent: nothing is created server-side and the same input yields the same vectors.', idempotent: true },
+ outputSchema: createEmbeddingsOutputSchema,
props: {
input: Property.Array({
displayName: 'Input',
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/create-library.ts b/packages/pieces/community/mistral-ai/src/lib/actions/create-library.ts
new file mode 100644
index 00000000000..277c458f234
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/create-library.ts
@@ -0,0 +1,51 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralLibrary } from '../common/libraries';
+import { libraryOutputSchema } from '../output-schemas';
+
+export const createLibrary = createAction({
+ auth: mistralAuth,
+ name: 'create_library',
+ classification: 'WRITE',
+ displayName: 'Create Library',
+ description: 'Create a document library for agents to search (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates an empty Mistral document library (Beta) and returns its UUID; add files with Upload Library Document and attach the library to an agent through Create Agent or Update Agent. Owner type User makes it private, Workspace shares it with the workspace. Not idempotent: each call creates another library, even with the same name.',
+ idempotent: false,
+ },
+ outputSchema: libraryOutputSchema,
+ props: {
+ name: Property.ShortText({ displayName: 'Name', required: true }),
+ description: Property.LongText({ displayName: 'Description', required: false }),
+ owner_type: Property.StaticDropdown({
+ displayName: 'Owner',
+ description: 'User keeps the library private; Workspace shares it with your workspace.',
+ required: false,
+ options: {
+ options: [
+ { label: 'User (private)', value: 'User' },
+ { label: 'Workspace', value: 'Workspace' },
+ ],
+ },
+ }),
+ chunk_size: Property.Number({
+ displayName: 'Chunk Size',
+ description: 'Characters per chunk when splitting documents, between 256 and 32768. Leave empty for the default.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { name, description, owner_type, chunk_size } = context.propsValue;
+ const library = await mistralApi.call<MistralLibrary>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/libraries',
+ body: mistralApi.compact({ name, description, owner_type, chunk_size }),
+ });
+ return libraryUtils.formatLibrary(library);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/delete-agent.ts b/packages/pieces/community/mistral-ai/src/lib/actions/delete-agent.ts
new file mode 100644
index 00000000000..72495ea5fea
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/delete-agent.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { deleteAgentOutputSchema } from '../output-schemas';
+
+export const deleteAgent = createAction({
+ auth: mistralAuth,
+ name: 'delete_agent',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Agent',
+ description: 'Permanently delete a Mistral agent (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a Mistral agent (Beta) and all its versions by agent id; conversations can no longer be started with it. Confirm the id with Get Agent or List Agents first. Not idempotent: a repeat call fails because the agent is gone.',
+ idempotent: false,
+ },
+ outputSchema: deleteAgentOutputSchema,
+ props: {
+ agent_id: Property.ShortText({
+ displayName: 'Agent ID',
+ description: 'The agent id (usually starts with ag_), from List Agents.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { agent_id } = context.propsValue;
+ await mistralApi.call<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/agents/${encodeURIComponent(agent_id)}`,
+ });
+ return { agent_id, deleted: true };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/delete-conversation.ts b/packages/pieces/community/mistral-ai/src/lib/actions/delete-conversation.ts
new file mode 100644
index 00000000000..3f17109b9aa
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/delete-conversation.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { conversationUtils } from '../common/conversations';
+import { deleteConversationOutputSchema } from '../output-schemas';
+
+export const deleteConversation = createAction({
+ auth: mistralAuth,
+ name: 'delete_conversation',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Conversation',
+ description: 'Permanently delete a stored conversation (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a stored conversation (Beta) and its history by conversation id; it can no longer be appended to or restarted. Confirm the id with List Conversations first. Not idempotent: a repeat call fails because the conversation is gone.',
+ idempotent: false,
+ },
+ outputSchema: deleteConversationOutputSchema,
+ props: {
+ conversation_id: conversationUtils.conversationIdProp(),
+ },
+ async run(context) {
+ const { conversation_id } = context.propsValue;
+ await mistralApi.call<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/conversations/${encodeURIComponent(conversation_id)}`,
+ });
+ return { conversation_id, deleted: true };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/delete-file.ts b/packages/pieces/community/mistral-ai/src/lib/actions/delete-file.ts
new file mode 100644
index 00000000000..9e171b76bbc
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/delete-file.ts
@@ -0,0 +1,35 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { deleteFileOutputSchema } from '../output-schemas';
+
+export const deleteFile = createAction({
+ auth: mistralAuth,
+ name: 'delete_file',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete File',
+ description: 'Permanently delete an uploaded file.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes one uploaded file and its metadata by UUID; this cannot be undone and breaks any batch job or OCR call that still references it. Confirm the id with List Files or Get File first. Not idempotent: a repeat call fails because the file is gone.',
+ idempotent: false,
+ },
+ outputSchema: deleteFileOutputSchema,
+ props: {
+ file_id: Property.ShortText({
+ displayName: 'File ID',
+ description: 'The file UUID, from List Files.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const response = await mistralApi.call<{ id: string; deleted: boolean }>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/files/${encodeURIComponent(context.propsValue.file_id)}`,
+ });
+ return { id: response.id, deleted: response.deleted };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/delete-library-document.ts b/packages/pieces/community/mistral-ai/src/lib/actions/delete-library-document.ts
new file mode 100644
index 00000000000..17a94684382
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/delete-library-document.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils } from '../common/libraries';
+import { deleteLibraryDocumentOutputSchema } from '../output-schemas';
+
+export const deleteLibraryDocument = createAction({
+ auth: mistralAuth,
+ name: 'delete_library_document',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Library Document',
+ description: 'Permanently remove a document from a library (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently removes one document from a library (Beta) by library and document UUID; agents using the library stop finding it. Use Delete Library to remove the whole library. Not idempotent: a repeat call fails because the document is gone.',
+ idempotent: false,
+ },
+ outputSchema: deleteLibraryDocumentOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ document_id: libraryUtils.documentIdProp(),
+ },
+ async run(context) {
+ const { library_id, document_id } = context.propsValue;
+ await mistralApi.call<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: libraryUtils.documentPath({ libraryId: library_id, documentId: document_id }),
+ });
+ return { library_id, document_id, deleted: true };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/delete-library.ts b/packages/pieces/community/mistral-ai/src/lib/actions/delete-library.ts
new file mode 100644
index 00000000000..2bc407b2466
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/delete-library.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralLibrary } from '../common/libraries';
+import { deleteLibraryOutputSchema } from '../output-schemas';
+
+export const deleteLibrary = createAction({
+ auth: mistralAuth,
+ name: 'delete_library',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Library',
+ description: 'Permanently delete a document library and all its documents (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a document library (Beta) and every document in it by UUID; agents that use it lose access. Use Delete Library Document to remove a single document instead. Not idempotent: a repeat call fails because the library is gone.',
+ idempotent: false,
+ },
+ outputSchema: deleteLibraryOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ },
+ async run(context) {
+ const library = await mistralApi.call<MistralLibrary>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/libraries/${encodeURIComponent(context.propsValue.library_id)}`,
+ });
+ return { ...libraryUtils.formatLibrary(library), deleted: true };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/download-file.ts b/packages/pieces/community/mistral-ai/src/lib/actions/download-file.ts
new file mode 100644
index 00000000000..83976e1bb5b
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/download-file.ts
@@ -0,0 +1,52 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { MistralFile } from '../common/files';
+import { downloadFileOutputSchema } from '../output-schemas';
+
+export const downloadFile = createAction({
+ auth: mistralAuth,
+ name: 'download_file',
+ classification: 'READ',
+ displayName: 'Download File',
+ description: 'Download the content of an uploaded file.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Downloads the content of one Mistral file by UUID and returns it as a file the flow can pass on, together with its name and size. Use it to fetch batch results or error files (their ids come from Get Batch Job) or anything else in List Files. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: downloadFileOutputSchema,
+ props: {
+ file_id: Property.ShortText({
+ displayName: 'File ID',
+ description: 'The file UUID, from List Files or a batch job’s output file.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const fileId = encodeURIComponent(context.propsValue.file_id);
+ const metadata = await mistralApi.call<MistralFile>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/files/${fileId}`,
+ });
+ const content = await mistralApi.call<ArrayBuffer>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/files/${fileId}/content`,
+ responseType: 'arraybuffer',
+ timeout: 300000,
+ });
+ const data = Buffer.from(content);
+ const file = await context.files.write({ fileName: metadata.filename, data });
+ return {
+ file,
+ file_id: metadata.id,
+ file_name: metadata.filename,
+ size_bytes: data.byteLength,
+ mimetype: metadata.mimetype ?? null,
+ };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/generate-chat-completion.ts b/packages/pieces/community/mistral-ai/src/lib/actions/generate-chat-completion.ts
new file mode 100644
index 00000000000..c3d04537181
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/generate-chat-completion.ts
@@ -0,0 +1,121 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { generateChatCompletionOutputSchema } from '../output-schemas';
+
+export const generateChatCompletion = createAction({
+ auth: mistralAuth,
+ name: 'generate_chat_completion',
+ classification: 'READ',
+ displayName: 'Generate Chat Completion',
+ description: 'Generate a reply from a Mistral chat model given a system prompt and a list of messages.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Generates one assistant reply from a Mistral chat model for a multi-turn message list, with an optional system prompt and JSON output mode, and returns the reply text plus finish reason and token usage. Pick this for stateless text generation where you supply the whole history; use Start Conversation instead when Mistral should store the thread or run a Mistral agent. Model ids come from List Models. Not idempotent: each call bills a new completion and the wording varies unless a random seed is set.',
+ idempotent: false,
+ },
+ outputSchema: generateChatCompletionOutputSchema,
+ props: {
+ model: Property.ShortText({
+ displayName: 'Model',
+ description: 'Chat model id, e.g. mistral-large-latest or mistral-small-latest. Use List Models to see what your key can access.',
+ required: true,
+ defaultValue: 'mistral-small-latest',
+ }),
+ system_prompt: Property.LongText({
+ displayName: 'System Prompt',
+ description: 'Optional instructions that set the model behaviour for the whole reply.',
+ required: false,
+ }),
+ messages: Property.Array({
+ displayName: 'Messages',
+ description: 'The conversation so far, oldest first. The last message is usually from the user.',
+ required: true,
+ properties: {
+ role: Property.StaticDropdown({
+ displayName: 'Role',
+ required: true,
+ defaultValue: 'user',
+ options: {
+ options: [
+ { label: 'User', value: 'user' },
+ { label: 'Assistant', value: 'assistant' },
+ ],
+ },
+ }),
+ content: Property.LongText({ displayName: 'Content', required: true }),
+ },
+ }),
+ response_format: Property.StaticDropdown({
+ displayName: 'Response Format',
+ description: 'Choose JSON to force the model to return a valid JSON object. Also ask for JSON in the prompt.',
+ required: false,
+ defaultValue: 'text',
+ options: {
+ options: [
+ { label: 'Text', value: 'text' },
+ { label: 'JSON object', value: 'json_object' },
+ ],
+ },
+ }),
+ temperature: Property.Number({
+ displayName: 'Temperature',
+ description: 'Sampling temperature between 0 and 1.5. Mistral recommends 0 to 0.7.',
+ required: false,
+ }),
+ max_tokens: Property.Number({
+ displayName: 'Max Tokens',
+ description: 'Maximum number of tokens to generate.',
+ required: false,
+ }),
+ random_seed: Property.Number({
+ displayName: 'Random Seed',
+ description: 'Set a seed to make repeated calls return the same output.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { model, system_prompt, messages, response_format, temperature, max_tokens, random_seed } = context.propsValue;
+ const conversation = (messages ?? []).filter(mistralApi.isRecord).map((message) => ({
+ role: message['role'] === 'assistant' ? 'assistant' : 'user',
+ content: String(message['content'] ?? ''),
+ }));
+ if (conversation.length === 0) {
+ throw new Error('Provide at least one message.');
+ }
+ const body = mistralApi.compact({
+ model,
+ messages: system_prompt ? [{ role: 'system', content: system_prompt }, ...conversation] : conversation,
+ response_format: response_format && response_format !== 'text' ? { type: response_format } : undefined,
+ temperature,
+ max_tokens,
+ random_seed,
+ });
+ const response = await mistralApi.call<ChatCompletionResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/chat/completions',
+ body,
+ timeout: 120000,
+ });
+ const choice = response.choices[0];
+ return {
+ id: response.id,
+ model: response.model,
+ content: mistralApi.contentToText(choice?.message?.content),
+ finish_reason: choice?.finish_reason ?? null,
+ prompt_tokens: response.usage?.prompt_tokens ?? null,
+ completion_tokens: response.usage?.completion_tokens ?? null,
+ total_tokens: response.usage?.total_tokens ?? null,
+ };
+ },
+});
+
+type ChatCompletionResponse = {
+ id: string;
+ model: string;
+ choices: { finish_reason: string; message?: { content: unknown } }[];
+ usage?: { prompt_tokens: number; completion_tokens: number; total_tokens: number };
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/generate-speech.ts b/packages/pieces/community/mistral-ai/src/lib/actions/generate-speech.ts
new file mode 100644
index 00000000000..c4f953f0078
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/generate-speech.ts
@@ -0,0 +1,79 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { generateSpeechOutputSchema } from '../output-schemas';
+
+export const generateSpeech = createAction({
+ auth: mistralAuth,
+ name: 'generate_speech',
+ classification: 'READ',
+ displayName: 'Generate Speech',
+ description: 'Turn text into a spoken audio file.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Converts text into spoken audio with Mistral text-to-speech and returns it as a file in the chosen format (mp3 by default). A voice is required: a preset slug (default en_paul_neutral) or a custom voice UUID. Use Transcribe Audio for the reverse direction. Not idempotent: each call bills a new generation and produces a new file.',
+ idempotent: false,
+ },
+ outputSchema: generateSpeechOutputSchema,
+ props: {
+ input: Property.LongText({
+ displayName: 'Text',
+ description: 'The text to speak.',
+ required: true,
+ }),
+ model: Property.ShortText({
+ displayName: 'Model',
+ description: 'Text-to-speech model id.',
+ required: true,
+ defaultValue: 'voxtral-mini-tts-latest',
+ }),
+ voice_id: Property.ShortText({
+ displayName: 'Voice',
+ description: 'A preset voice slug such as en_paul_neutral, en_paul_happy or en_paul_sad, or the UUID of a custom voice.',
+ required: true,
+ defaultValue: 'en_paul_neutral',
+ }),
+ response_format: Property.StaticDropdown({
+ displayName: 'Audio Format',
+ required: false,
+ defaultValue: 'mp3',
+ options: {
+ options: [
+ { label: 'MP3', value: 'mp3' },
+ { label: 'WAV', value: 'wav' },
+ { label: 'FLAC', value: 'flac' },
+ { label: 'Opus', value: 'opus' },
+ { label: 'PCM', value: 'pcm' },
+ ],
+ },
+ }),
+ file_name: Property.ShortText({
+ displayName: 'File Name',
+ description: 'Name for the audio file, without extension.',
+ required: false,
+ defaultValue: 'speech',
+ }),
+ },
+ async run(context) {
+ const { input, model, voice_id, response_format, file_name } = context.propsValue;
+ const format = response_format ?? 'mp3';
+ const response = await mistralApi.call<{ audio_data: string }>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/audio/speech',
+ body: mistralApi.compact({ input, model, voice_id, response_format: format, stream: false }),
+ timeout: 300000,
+ });
+ const data = Buffer.from(response.audio_data, 'base64');
+ const fileName = `${file_name || 'speech'}.${format}`;
+ const file = await context.files.write({ fileName, data });
+ return {
+ file,
+ file_name: fileName,
+ format,
+ size_bytes: data.byteLength,
+ };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-agent.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-agent.ts
new file mode 100644
index 00000000000..0742189edb1
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-agent.ts
@@ -0,0 +1,43 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { agentUtils, MistralAgent } from '../common/agents';
+import { agentOutputSchema } from '../output-schemas';
+
+export const getAgent = createAction({
+ auth: mistralAuth,
+ name: 'get_agent',
+ classification: 'READ',
+ displayName: 'Get Agent',
+ description: 'Get the configuration of a Mistral agent (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one Mistral agent’s configuration (Beta) by agent id: model, instructions, tools, libraries and version numbers, optionally at a specific version. Get agent ids from List Agents or Create Agent. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: agentOutputSchema,
+ props: {
+ agent_id: Property.ShortText({
+ displayName: 'Agent ID',
+ description: 'The agent id (usually starts with ag_), from List Agents.',
+ required: true,
+ }),
+ agent_version: Property.Number({
+ displayName: 'Version',
+ description: 'Return this version instead of the current one.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { agent_id, agent_version } = context.propsValue;
+ const agent = await mistralApi.call<MistralAgent>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/agents/${encodeURIComponent(agent_id)}`,
+ queryParams: { agent_version },
+ });
+ return agentUtils.formatAgent(agent);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-batch-job.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-batch-job.ts
new file mode 100644
index 00000000000..892b0a86bb5
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-batch-job.ts
@@ -0,0 +1,40 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { batchUtils, MistralBatchJob } from '../common/batch';
+import { batchJobOutputSchema } from '../output-schemas';
+
+export const getBatchJob = createAction({
+ auth: mistralAuth,
+ name: 'get_batch_job',
+ classification: 'READ',
+ displayName: 'Get Batch Job',
+ description: 'Check the status and results of a batch job.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one batch job’s current status and request counts, plus the output and error file ids once it finishes; this is a single check, so call it again until the status is SUCCESS, FAILED, TIMEOUT_EXCEEDED or CANCELLED. Download results with Download File using the output file id, or enable Inline Results for small jobs. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: batchJobOutputSchema,
+ props: {
+ job_id: batchUtils.jobIdProp(),
+ inline: Property.Checkbox({
+ displayName: 'Inline Results',
+ description: 'Include the results in the response instead of only an output file id. Only for small jobs.',
+ required: false,
+ defaultValue: false,
+ }),
+ },
+ async run(context) {
+ const { job_id, inline } = context.propsValue;
+ const job = await mistralApi.call<MistralBatchJob>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/batch/jobs/${encodeURIComponent(job_id)}`,
+ queryParams: { inline: inline ? true : undefined },
+ });
+ return batchUtils.formatJob(job);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation-history.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation-history.ts
new file mode 100644
index 00000000000..20f9e486729
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation-history.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { ConversationEntry, conversationUtils } from '../common/conversations';
+import { conversationHistoryOutputSchema } from '../output-schemas';
+
+export const getConversationHistory = createAction({
+ auth: mistralAuth,
+ name: 'get_conversation_history',
+ classification: 'READ',
+ displayName: 'Get Conversation History',
+ description: 'Get every entry of a conversation, including tool calls (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns every entry of a stored conversation (Beta) in order: user and assistant messages plus tool executions, function calls and agent handoffs, each with its entry id. Use it to find the entry id Restart Conversation needs, or to audit what tools an agent ran; use Get Conversation Messages when you only need the messages. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: conversationHistoryOutputSchema,
+ props: {
+ conversation_id: conversationUtils.conversationIdProp(),
+ },
+ async run(context) {
+ const response = await mistralApi.call<{ conversation_id: string; entries: ConversationEntry[] }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/conversations/${encodeURIComponent(context.propsValue.conversation_id)}/history`,
+ });
+ const entries = response.entries.map(conversationUtils.formatEntry);
+ return { conversation_id: response.conversation_id, entries, count: entries.length };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation-messages.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation-messages.ts
new file mode 100644
index 00000000000..ca1bf7cc3be
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation-messages.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { ConversationEntry, conversationUtils } from '../common/conversations';
+import { conversationMessagesOutputSchema } from '../output-schemas';
+
+export const getConversationMessages = createAction({
+ auth: mistralAuth,
+ name: 'get_conversation_messages',
+ classification: 'READ',
+ displayName: 'Get Conversation Messages',
+ description: 'Get the user and assistant messages of a conversation (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns only the user and assistant messages of a stored conversation (Beta), in order, as role and text. Use it to read the transcript; use Get Conversation History when you also need tool calls or entry ids. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: conversationMessagesOutputSchema,
+ props: {
+ conversation_id: conversationUtils.conversationIdProp(),
+ },
+ async run(context) {
+ const response = await mistralApi.call<{ conversation_id: string; messages: ConversationEntry[] }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/conversations/${encodeURIComponent(context.propsValue.conversation_id)}/messages`,
+ });
+ const messages = response.messages.map(conversationUtils.formatEntry);
+ return { conversation_id: response.conversation_id, messages, count: messages.length };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation.ts
new file mode 100644
index 00000000000..aefb59aa130
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-conversation.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { conversationUtils, MistralConversation } from '../common/conversations';
+import { conversationOutputSchema } from '../output-schemas';
+
+export const getConversation = createAction({
+ auth: mistralAuth,
+ name: 'get_conversation',
+ classification: 'READ',
+ displayName: 'Get Conversation',
+ description: 'Get the details of a stored conversation (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one stored conversation’s metadata (Beta): name, agent or model, instructions and timestamps. It does not include the messages; use Get Conversation Messages or Get Conversation History for those. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: conversationOutputSchema,
+ props: {
+ conversation_id: conversationUtils.conversationIdProp(),
+ },
+ async run(context) {
+ const conversation = await mistralApi.call<MistralConversation>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/conversations/${encodeURIComponent(context.propsValue.conversation_id)}`,
+ });
+ return conversationUtils.formatConversation(conversation);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-document-status.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-document-status.ts
new file mode 100644
index 00000000000..4c94750f190
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-document-status.ts
@@ -0,0 +1,39 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils } from '../common/libraries';
+import { documentStatusOutputSchema } from '../output-schemas';
+
+export const getDocumentStatus = createAction({
+ auth: mistralAuth,
+ name: 'get_document_status',
+ classification: 'READ',
+ displayName: 'Get Document Status',
+ description: 'Check whether a library document has finished processing (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns the processing status of one library document (Beta), e.g. todo, in_progress, done or error, with an is_done flag. Poll it after Upload Library Document or Reprocess Document; one call is a single check, not a wait. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: documentStatusOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ document_id: libraryUtils.documentIdProp(),
+ },
+ async run(context) {
+ const { library_id, document_id } = context.propsValue;
+ const status = await mistralApi.call<{ document_id: string; process_status: string }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `${libraryUtils.documentPath({ libraryId: library_id, documentId: document_id })}/status`,
+ });
+ return {
+ document_id: status.document_id,
+ process_status: status.process_status,
+ is_done: status.process_status === 'done',
+ is_error: status.process_status === 'error',
+ };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-document-text-content.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-document-text-content.ts
new file mode 100644
index 00000000000..1cf77ed8c85
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-document-text-content.ts
@@ -0,0 +1,37 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils } from '../common/libraries';
+import { documentTextContentOutputSchema } from '../output-schemas';
+
+export const getDocumentTextContent = createAction({
+ auth: mistralAuth,
+ name: 'get_document_text_content',
+ classification: 'READ',
+ displayName: 'Get Document Text Content',
+ description: 'Get the text Mistral extracted from a library document (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns the text Mistral extracted from a processed library document (Beta), optionally limited to a page range. The document must have finished processing; check Get Document Status first. Use OCR instead for files that are not in a library. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: documentTextContentOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ document_id: libraryUtils.documentIdProp(),
+ page_start: Property.Number({ displayName: 'First Page', required: false }),
+ page_end: Property.Number({ displayName: 'Last Page', required: false }),
+ },
+ async run(context) {
+ const { library_id, document_id, page_start, page_end } = context.propsValue;
+ const response = await mistralApi.call<{ text: string }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `${libraryUtils.documentPath({ libraryId: library_id, documentId: document_id })}/text_content`,
+ queryParams: { page_start, page_end },
+ });
+ return { document_id, text: response.text, length: response.text.length };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-file-signed-url.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-file-signed-url.ts
new file mode 100644
index 00000000000..74bd527b6c0
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-file-signed-url.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { getFileSignedUrlOutputSchema } from '../output-schemas';
+
+export const getFileSignedUrl = createAction({
+ auth: mistralAuth,
+ name: 'get_file_signed_url',
+ classification: 'READ',
+ displayName: 'Get File Download URL',
+ description: 'Get a temporary link to download an uploaded file.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates a time-limited signed URL (1 to 168 hours, default 24) that downloads one uploaded file without an API key. Use it to hand a file to another service by link; use Download File when the flow itself needs the bytes. Each call issues a new URL, but nothing is changed in the account.',
+ idempotent: true,
+ },
+ outputSchema: getFileSignedUrlOutputSchema,
+ props: {
+ file_id: Property.ShortText({
+ displayName: 'File ID',
+ description: 'The file UUID, from List Files.',
+ required: true,
+ }),
+ expiry_hours: Property.Number({
+ displayName: 'Expiry (hours)',
+ description: 'How long the link stays valid, between 1 and 168 hours.',
+ required: false,
+ defaultValue: 24,
+ }),
+ },
+ async run(context) {
+ const { file_id, expiry_hours } = context.propsValue;
+ const expiry = expiry_hours ?? 24;
+ const response = await mistralApi.call<{ url: string }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/files/${encodeURIComponent(file_id)}/url`,
+ queryParams: { expiry },
+ });
+ return {
+ file_id,
+ url: response.url,
+ expires_at: new Date(Date.now() + expiry * 3600 * 1000).toISOString(),
+ };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-file.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-file.ts
new file mode 100644
index 00000000000..94e337ec8ae
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-file.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { fileUtils, MistralFile } from '../common/files';
+import { fileOutputSchema } from '../output-schemas';
+
+export const getFile = createAction({
+ auth: mistralAuth,
+ name: 'get_file',
+ classification: 'READ',
+ displayName: 'Get File',
+ description: 'Get the details of an uploaded file.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns the metadata of one uploaded file by UUID: name, purpose, size, MIME type, source and creation time. It does not return the content; use Download File for that. Get file ids from List Files or Upload File. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: fileOutputSchema,
+ props: {
+ file_id: Property.ShortText({
+ displayName: 'File ID',
+ description: 'The file UUID, from List Files or Upload File.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const file = await mistralApi.call<MistralFile>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/files/${encodeURIComponent(context.propsValue.file_id)}`,
+ });
+ return fileUtils.formatFile(file);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-library-document.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-library-document.ts
new file mode 100644
index 00000000000..db6cc8d93fd
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-library-document.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralDocument } from '../common/libraries';
+import { documentOutputSchema } from '../output-schemas';
+
+export const getLibraryDocument = createAction({
+ auth: mistralAuth,
+ name: 'get_library_document',
+ classification: 'READ',
+ displayName: 'Get Library Document',
+ description: 'Get the details of a document in a library (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one library document’s metadata (Beta): name, type, size, page count, summary, attributes and processing status. Use Get Document Text Content for the text itself. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: documentOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ document_id: libraryUtils.documentIdProp(),
+ },
+ async run(context) {
+ const { library_id, document_id } = context.propsValue;
+ const document = await mistralApi.call<MistralDocument>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: libraryUtils.documentPath({ libraryId: library_id, documentId: document_id }),
+ });
+ return libraryUtils.formatDocument(document);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-library.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-library.ts
new file mode 100644
index 00000000000..f1d4ae05329
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-library.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralLibrary } from '../common/libraries';
+import { libraryOutputSchema } from '../output-schemas';
+
+export const getLibrary = createAction({
+ auth: mistralAuth,
+ name: 'get_library',
+ classification: 'READ',
+ displayName: 'Get Library',
+ description: 'Get the details of a document library (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one document library’s details (Beta) by UUID: name, description, owner, document count, total size and chunk size. Use List Library Documents to see its documents. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: libraryOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ },
+ async run(context) {
+ const library = await mistralApi.call<MistralLibrary>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/libraries/${encodeURIComponent(context.propsValue.library_id)}`,
+ });
+ return libraryUtils.formatLibrary(library);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/get-model.ts b/packages/pieces/community/mistral-ai/src/lib/actions/get-model.ts
new file mode 100644
index 00000000000..0deada12279
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/get-model.ts
@@ -0,0 +1,61 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { getModelOutputSchema } from '../output-schemas';
+
+export const getModel = createAction({
+ auth: mistralAuth,
+ name: 'get_model',
+ classification: 'READ',
+ displayName: 'Get Model',
+ description: 'Get details and capabilities of one Mistral model.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one model’s details by id: capabilities (chat, function calling, vision, fine-tuning, OCR, audio), context length, aliases, owner and deprecation date. Use it to check what a model supports before calling it; use List Models to discover ids. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: getModelOutputSchema,
+ props: {
+ model_id: Property.ShortText({
+ displayName: 'Model ID',
+ description: 'The model id, e.g. mistral-large-latest or a fine-tuned id starting with ft:.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const model = await mistralApi.call<ModelCard>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/models/${encodeURIComponent(context.propsValue.model_id)}`,
+ });
+ return {
+ id: model.id,
+ name: model.name ?? null,
+ description: model.description ?? null,
+ type: model.type ?? null,
+ owned_by: model.owned_by ?? null,
+ created: model.created ?? null,
+ max_context_length: model.max_context_length ?? null,
+ aliases: model.aliases ?? [],
+ deprecation: model.deprecation ?? null,
+ default_model_temperature: model.default_model_temperature ?? null,
+ capabilities: model.capabilities ?? {},
+ };
+ },
+});
+
+type ModelCard = {
+ id: string;
+ name?: string | null;
+ description?: string | null;
+ type?: string;
+ owned_by?: string;
+ created?: number;
+ max_context_length?: number;
+ aliases?: string[];
+ deprecation?: string | null;
+ default_model_temperature?: number | null;
+ capabilities?: Record<string, boolean>;
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/list-agents.ts b/packages/pieces/community/mistral-ai/src/lib/actions/list-agents.ts
new file mode 100644
index 00000000000..9a25a441de6
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/list-agents.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { agentUtils, MistralAgent } from '../common/agents';
+import { listAgentsOutputSchema } from '../output-schemas';
+
+export const listAgents = createAction({
+ auth: mistralAuth,
+ name: 'list_agents',
+ classification: 'SEARCH',
+ displayName: 'List Agents',
+ description: 'List the Mistral agents in your organization (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists Mistral agents (Beta) with their ids, names, models, instructions and tools, optionally filtered by a name or id search, one page at a time. Use it to find the agent id for Start Conversation, Get Agent, Update Agent or Delete Agent. Pass the returned next page token to get the next page. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: listAgentsOutputSchema,
+ props: {
+ search: Property.ShortText({
+ displayName: 'Search',
+ description: 'Only return agents whose name or id contains this text.',
+ required: false,
+ }),
+ page_size: Property.Number({ displayName: 'Page Size', required: false, defaultValue: 20 }),
+ page_token: Property.ShortText({
+ displayName: 'Page Token',
+ description: 'The next page token from a previous call.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { search, page_size, page_token } = context.propsValue;
+ const response = await mistralApi.call<{ data: MistralAgent[]; next_page_token?: string | null }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/agents/pages',
+ queryParams: { search, page_size, page_token },
+ });
+ const agents = response.data.map(agentUtils.formatAgent);
+ return {
+ agents,
+ count: agents.length,
+ next_page_token: response.next_page_token ?? null,
+ };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/list-batch-jobs.ts b/packages/pieces/community/mistral-ai/src/lib/actions/list-batch-jobs.ts
new file mode 100644
index 00000000000..7a3b827565f
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/list-batch-jobs.ts
@@ -0,0 +1,42 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { BATCH_STATUS_OPTIONS, batchUtils, MistralBatchJob } from '../common/batch';
+import { listBatchJobsOutputSchema } from '../output-schemas';
+
+export const listBatchJobs = createAction({
+ auth: mistralAuth,
+ name: 'list_batch_jobs',
+ classification: 'SEARCH',
+ displayName: 'List Batch Jobs',
+ description: 'List batch inference jobs.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists batch inference jobs with their UUIDs, status, endpoint, model and request counts, newest first, optionally filtered by status or model, one page at a time. Use it to find a job id for Get Batch Job or Cancel Batch Job. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: listBatchJobsOutputSchema,
+ props: {
+ status: Property.StaticDropdown({
+ displayName: 'Status',
+ required: false,
+ options: { options: BATCH_STATUS_OPTIONS },
+ }),
+ model: Property.ShortText({ displayName: 'Model', required: false }),
+ page: Property.Number({ displayName: 'Page', description: 'Zero-based page number.', required: false, defaultValue: 0 }),
+ page_size: Property.Number({ displayName: 'Page Size', required: false, defaultValue: 100 }),
+ },
+ async run(context) {
+ const { status, model, page, page_size } = context.propsValue;
+ const response = await mistralApi.call<{ data?: MistralBatchJob[]; total: number }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/batch/jobs',
+ queryParams: { status, model, page, page_size, order_by: '-created' },
+ });
+ const jobs = (response.data ?? []).map(batchUtils.formatJob);
+ return { jobs, count: jobs.length, total: response.total };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/list-conversations.ts b/packages/pieces/community/mistral-ai/src/lib/actions/list-conversations.ts
new file mode 100644
index 00000000000..c04f4dbebdf
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/list-conversations.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { conversationUtils, MistralConversation } from '../common/conversations';
+import { listConversationsOutputSchema } from '../output-schemas';
+
+export const listConversations = createAction({
+ auth: mistralAuth,
+ name: 'list_conversations',
+ classification: 'SEARCH',
+ displayName: 'List Conversations',
+ description: 'List stored conversations (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists stored Mistral conversations (Beta) with their ids, names, agent or model, and timestamps, one page at a time. Use it to find a conversation id for Append, Restart, History, Messages or Delete. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: listConversationsOutputSchema,
+ props: {
+ page: Property.Number({ displayName: 'Page', description: 'Zero-based page number.', required: false, defaultValue: 0 }),
+ page_size: Property.Number({ displayName: 'Page Size', required: false, defaultValue: 100 }),
+ },
+ async run(context) {
+ const { page, page_size } = context.propsValue;
+ const response = await mistralApi.call<MistralConversation[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/conversations',
+ queryParams: { page, page_size },
+ });
+ const conversations = response.map(conversationUtils.formatConversation);
+ return { conversations, count: conversations.length };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/list-files.ts b/packages/pieces/community/mistral-ai/src/lib/actions/list-files.ts
new file mode 100644
index 00000000000..eb52f0a1021
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/list-files.ts
@@ -0,0 +1,60 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { FILE_PURPOSE_OPTIONS, fileUtils, MistralFile } from '../common/files';
+import { listFilesOutputSchema } from '../output-schemas';
+
+export const listFiles = createAction({
+ auth: mistralAuth,
+ name: 'list_files',
+ classification: 'SEARCH',
+ displayName: 'List Files',
+ description: 'List files uploaded to your Mistral account.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists files stored in the Mistral account with their UUIDs, names, purpose, size and creation time, optionally filtered by purpose or a filename search, one page at a time. Use it to find a file id for Get File, Delete File, Download File, OCR, transcription or a batch job. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: listFilesOutputSchema,
+ props: {
+ purpose: Property.StaticDropdown({
+ displayName: 'Purpose',
+ description: 'Only return files uploaded for this purpose.',
+ required: false,
+ options: { options: FILE_PURPOSE_OPTIONS },
+ }),
+ search: Property.ShortText({
+ displayName: 'Search',
+ description: 'Only return files whose name contains this text.',
+ required: false,
+ }),
+ page: Property.Number({
+ displayName: 'Page',
+ description: 'Zero-based page number.',
+ required: false,
+ defaultValue: 0,
+ }),
+ page_size: Property.Number({
+ displayName: 'Page Size',
+ required: false,
+ defaultValue: 100,
+ }),
+ },
+ async run(context) {
+ const { purpose, search, page, page_size } = context.propsValue;
+ const response = await mistralApi.call<{ data: MistralFile[]; total?: number | null }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/files',
+ queryParams: { purpose, search, page, page_size, include_total: true },
+ });
+ const files = response.data.map(fileUtils.formatFile);
+ return {
+ files,
+ count: files.length,
+ total: response.total ?? null,
+ };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/list-libraries.ts b/packages/pieces/community/mistral-ai/src/lib/actions/list-libraries.ts
new file mode 100644
index 00000000000..9b830ef1911
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/list-libraries.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralLibrary } from '../common/libraries';
+import { listLibrariesOutputSchema } from '../output-schemas';
+
+export const listLibraries = createAction({
+ auth: mistralAuth,
+ name: 'list_libraries',
+ classification: 'SEARCH',
+ displayName: 'List Libraries',
+ description: 'List document libraries you can access (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists Mistral document libraries (Beta) with their UUIDs, names, document counts and sizes, optionally filtered by a name search, one page at a time. Use it to find a library id for the document actions or for an agent’s document library tool. Pass the returned next page token to get the next page. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: listLibrariesOutputSchema,
+ props: {
+ search: Property.ShortText({
+ displayName: 'Search',
+ description: 'Only return libraries whose name contains this text.',
+ required: false,
+ }),
+ page_size: Property.Number({ displayName: 'Page Size', required: false, defaultValue: 100 }),
+ page_token: Property.ShortText({
+ displayName: 'Page Token',
+ description: 'The next page token from a previous call.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { search, page_size, page_token } = context.propsValue;
+ const response = await mistralApi.call<{ data: MistralLibrary[]; next_page_token?: string | null }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/libraries',
+ queryParams: { search, page_size, page_token },
+ });
+ const libraries = response.data.map(libraryUtils.formatLibrary);
+ return {
+ libraries,
+ count: libraries.length,
+ next_page_token: response.next_page_token ?? null,
+ };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/list-library-documents.ts b/packages/pieces/community/mistral-ai/src/lib/actions/list-library-documents.ts
new file mode 100644
index 00000000000..a9f92c6ca7b
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/list-library-documents.ts
@@ -0,0 +1,47 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralDocument } from '../common/libraries';
+import { listLibraryDocumentsOutputSchema } from '../output-schemas';
+
+export const listLibraryDocuments = createAction({
+ auth: mistralAuth,
+ name: 'list_library_documents',
+ classification: 'SEARCH',
+ displayName: 'List Library Documents',
+ description: 'List the documents in a library (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the documents in one library (Beta) with their UUIDs, names, sizes, summaries and processing status, optionally filtered by a name search, one page at a time. Use it to find a document id for the other document actions. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: listLibraryDocumentsOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ search: Property.ShortText({
+ displayName: 'Search',
+ description: 'Only return documents whose name contains this text.',
+ required: false,
+ }),
+ page: Property.Number({ displayName: 'Page', description: 'Zero-based page number.', required: false, defaultValue: 0 }),
+ page_size: Property.Number({ displayName: 'Page Size', required: false, defaultValue: 100 }),
+ },
+ async run(context) {
+ const { library_id, search, page, page_size } = context.propsValue;
+ const response = await mistralApi.call<{ data: MistralDocument[]; pagination?: { total_items?: number; has_more?: boolean } }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/libraries/${encodeURIComponent(library_id)}/documents`,
+ queryParams: { search, page, page_size },
+ });
+ const documents = response.data.map(libraryUtils.formatDocument);
+ return {
+ documents,
+ count: documents.length,
+ total: response.pagination?.total_items ?? null,
+ has_more: response.pagination?.has_more ?? null,
+ };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/list-models.ts b/packages/pieces/community/mistral-ai/src/lib/actions/list-models.ts
index 2c296e0f366..dc6f245c6f9 100644
--- a/packages/pieces/community/mistral-ai/src/lib/actions/list-models.ts
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/list-models.ts
@@ -3,6 +3,7 @@ import { HttpMethod, httpClient } from '@activepieces/pieces-common';
import { mistralAuth } from '../common/auth';
import { parseMistralError } from '../common/props';
import { mistralRequest } from '../common/request';
+import { listModelsOutputSchema } from '../output-schemas';
export const listModels = createAction({
audience: 'both',
@@ -12,6 +13,7 @@ export const listModels = createAction({
displayName: 'List Models',
description: 'Retrieves a list of available Mistral AI models.',
aiMetadata: { description: 'Returns every model the connected Mistral key can access, chat, embedding and OCR ids alike, exactly as the models endpoint reports them. Use it to discover a valid model id before calling Ask Mistral or Run OCR, both of which require one; it is the only discovery action here and takes no inputs, so it cannot filter or search. Read-only and idempotent.', idempotent: true },
+ outputSchema: listModelsOutputSchema,
props: {},
async run({ auth }) {
try {
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/moderate-chat.ts b/packages/pieces/community/mistral-ai/src/lib/actions/moderate-chat.ts
new file mode 100644
index 00000000000..c8b022e9c75
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/moderate-chat.ts
@@ -0,0 +1,64 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { moderationUtils, ModerationResponse } from '../common/moderation';
+import { moderateChatOutputSchema } from '../output-schemas';
+
+export const moderateChat = createAction({
+ auth: mistralAuth,
+ name: 'moderate_chat',
+ classification: 'READ',
+ displayName: 'Moderate Chat',
+ description: 'Check a conversation for harmful content.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Classifies a conversation (user and assistant turns) against Mistral’s moderation categories, judging the last turn in the context of the earlier ones, and returns flags, scores and the flagged categories. Use this for chat transcripts; use Moderate Text for standalone strings. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: moderateChatOutputSchema,
+ props: {
+ messages: Property.Array({
+ displayName: 'Messages',
+ description: 'The conversation to check, oldest first.',
+ required: true,
+ properties: {
+ role: Property.StaticDropdown({
+ displayName: 'Role',
+ required: true,
+ defaultValue: 'user',
+ options: {
+ options: [
+ { label: 'User', value: 'user' },
+ { label: 'Assistant', value: 'assistant' },
+ { label: 'System', value: 'system' },
+ ],
+ },
+ }),
+ content: Property.LongText({ displayName: 'Content', required: true }),
+ },
+ }),
+ model: Property.ShortText({
+ displayName: 'Model',
+ required: true,
+ defaultValue: 'mistral-moderation-latest',
+ }),
+ },
+ async run(context) {
+ const messages = (context.propsValue.messages ?? []).filter(mistralApi.isRecord).map((message) => ({
+ role: String(message['role'] ?? 'user'),
+ content: String(message['content'] ?? ''),
+ }));
+ if (messages.length === 0) {
+ throw new Error('Provide at least one message.');
+ }
+ const response = await mistralApi.call<ModerationResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/chat/moderations',
+ body: { model: context.propsValue.model, input: messages },
+ });
+ return moderationUtils.formatResponse({ response, inputs: [messages[messages.length - 1].content] });
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/moderate-text.ts b/packages/pieces/community/mistral-ai/src/lib/actions/moderate-text.ts
new file mode 100644
index 00000000000..b67ab7076c8
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/moderate-text.ts
@@ -0,0 +1,46 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { moderationUtils, ModerationResponse } from '../common/moderation';
+import { moderateTextOutputSchema } from '../output-schemas';
+
+export const moderateText = createAction({
+ auth: mistralAuth,
+ name: 'moderate_text',
+ classification: 'READ',
+ displayName: 'Moderate Text',
+ description: 'Check one or more texts for harmful content.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Classifies one or more plain texts against Mistral’s moderation categories (sexual, hate, violence, self-harm, PII and more) and returns per-text flags and scores plus the list of flagged categories. Use this for standalone text; use Moderate Chat when the content is a conversation so the assistant turn is judged in context. Read-only; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: moderateTextOutputSchema,
+ props: {
+ texts: Property.Array({
+ displayName: 'Texts',
+ description: 'One or more texts to check. Each is scored separately.',
+ required: true,
+ }),
+ model: Property.ShortText({
+ displayName: 'Model',
+ required: true,
+ defaultValue: 'mistral-moderation-latest',
+ }),
+ },
+ async run(context) {
+ const texts = mistralApi.toStringArray(context.propsValue.texts);
+ if (texts.length === 0) {
+ throw new Error('Provide at least one text.');
+ }
+ const response = await mistralApi.call<ModerationResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/moderations',
+ body: { model: context.propsValue.model, input: texts },
+ });
+ return moderationUtils.formatResponse({ response, inputs: texts });
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/reprocess-document.ts b/packages/pieces/community/mistral-ai/src/lib/actions/reprocess-document.ts
new file mode 100644
index 00000000000..a6fa2a5eaa7
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/reprocess-document.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils } from '../common/libraries';
+import { reprocessDocumentOutputSchema } from '../output-schemas';
+
+export const reprocessDocument = createAction({
+ auth: mistralAuth,
+ name: 'reprocess_document',
+ classification: 'WRITE',
+ displayName: 'Reprocess Document',
+ description: 'Run text extraction and indexing again for a library document (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Queues a library document (Beta) to be processed again, re-extracting and re-indexing its text, for example after a processing error. It returns once queued; poll Get Document Status for the result. Not idempotent: each call starts a new processing run.',
+ idempotent: false,
+ },
+ outputSchema: reprocessDocumentOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ document_id: libraryUtils.documentIdProp(),
+ },
+ async run(context) {
+ const { library_id, document_id } = context.propsValue;
+ await mistralApi.call<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `${libraryUtils.documentPath({ libraryId: library_id, documentId: document_id })}/reprocess`,
+ });
+ return { library_id, document_id, reprocessing: true };
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/restart-conversation.ts b/packages/pieces/community/mistral-ai/src/lib/actions/restart-conversation.ts
new file mode 100644
index 00000000000..ee7c035d766
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/restart-conversation.ts
@@ -0,0 +1,45 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { conversationUtils, ConversationResponse } from '../common/conversations';
+import { conversationReplyOutputSchema } from '../output-schemas';
+
+export const restartConversation = createAction({
+ auth: mistralAuth,
+ name: 'restart_conversation',
+ classification: 'WRITE',
+ displayName: 'Restart Conversation',
+ description: 'Branch a conversation from an earlier entry with a new message (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates a new conversation branch (Beta) that keeps the original history up to a chosen entry, then sends a new message from that point and returns the reply and the new conversation id; the original conversation is left unchanged. The entry id is required; get it from Get Conversation History. Use Append to Conversation to simply continue. Not idempotent: each call creates a new branch.',
+ idempotent: false,
+ },
+ outputSchema: conversationReplyOutputSchema,
+ props: {
+ conversation_id: conversationUtils.conversationIdProp(),
+ from_entry_id: Property.ShortText({
+ displayName: 'From Entry ID',
+ description: 'The entry to restart from, from Get Conversation History.',
+ required: true,
+ }),
+ message: Property.LongText({
+ displayName: 'Message',
+ description: 'The new user message to send from that point.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { conversation_id, from_entry_id, message } = context.propsValue;
+ const response = await mistralApi.call<ConversationResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/conversations/${encodeURIComponent(conversation_id)}/restart`,
+ body: { inputs: message, from_entry_id, stream: false, store: true },
+ timeout: 300000,
+ });
+ return conversationUtils.formatResponse(response);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/start-conversation.ts b/packages/pieces/community/mistral-ai/src/lib/actions/start-conversation.ts
new file mode 100644
index 00000000000..2ff7a1428f5
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/start-conversation.ts
@@ -0,0 +1,75 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { conversationUtils, ConversationResponse } from '../common/conversations';
+import { conversationReplyOutputSchema } from '../output-schemas';
+
+export const startConversation = createAction({
+ auth: mistralAuth,
+ name: 'start_conversation',
+ classification: 'WRITE',
+ displayName: 'Start Conversation',
+ description: 'Start a stored conversation with a Mistral agent or model (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Starts a new server-side conversation (Beta) with either a Mistral agent (agent id) or a plain model, sends the first message and returns the reply text, all output entries (including tool calls) and the conversation id. This is how you run a Mistral agent; continue with Append to Conversation. Use Generate Chat Completion instead for one-off stateless replies. Not idempotent: each call creates a new conversation and bills a new reply.',
+ idempotent: false,
+ },
+ outputSchema: conversationReplyOutputSchema,
+ props: {
+ message: Property.LongText({
+ displayName: 'Message',
+ description: 'The first user message.',
+ required: true,
+ }),
+ agent_id: Property.ShortText({
+ displayName: 'Agent ID',
+ description: 'Run this agent (from List Agents). Leave empty to talk to a model directly.',
+ required: false,
+ }),
+ model: Property.ShortText({
+ displayName: 'Model',
+ description: 'Model id to use when no agent is given, e.g. mistral-medium-latest.',
+ required: false,
+ }),
+ instructions: Property.LongText({
+ displayName: 'Instructions',
+ description: 'System instructions, only used when talking to a model directly.',
+ required: false,
+ }),
+ name: Property.ShortText({ displayName: 'Conversation Name', required: false }),
+ store: Property.Checkbox({
+ displayName: 'Store Conversation',
+ description: 'Keep the conversation on Mistral so it can be continued later.',
+ required: false,
+ defaultValue: true,
+ }),
+ },
+ async run(context) {
+ const { message, agent_id, model, instructions, name, store } = context.propsValue;
+ if (!agent_id && !model) {
+ throw new Error('Provide either an Agent ID or a Model.');
+ }
+ if (agent_id && model) {
+ throw new Error('Provide only one of Agent ID or Model.');
+ }
+ const response = await mistralApi.call<ConversationResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/conversations',
+ body: mistralApi.compact({
+ inputs: message,
+ agent_id,
+ model,
+ instructions: agent_id ? undefined : instructions,
+ name,
+ store: store ?? true,
+ stream: false,
+ }),
+ timeout: 300000,
+ });
+ return conversationUtils.formatResponse(response);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/transcribe-audio.ts b/packages/pieces/community/mistral-ai/src/lib/actions/transcribe-audio.ts
new file mode 100644
index 00000000000..42db5764174
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/transcribe-audio.ts
@@ -0,0 +1,126 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import FormData from 'form-data';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { transcribeAudioOutputSchema } from '../output-schemas';
+
+export const transcribeAudio = createAction({
+ auth: mistralAuth,
+ name: 'transcribe_audio',
+ classification: 'READ',
+ displayName: 'Transcribe Audio',
+ description: 'Convert speech in an audio file to text with a Voxtral model.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Transcribes speech to text with a Mistral Voxtral model and returns the full text, detected language and optional timestamped segments. Provide exactly one source: an audio file, a public audio URL, or the id of a file already uploaded to Mistral. Setting the language improves accuracy; diarization labels speakers. Read-only, stores nothing; safe to retry.',
+ idempotent: true,
+ },
+ outputSchema: transcribeAudioOutputSchema,
+ props: {
+ model: Property.StaticDropdown({
+ displayName: 'Model',
+ required: true,
+ defaultValue: 'voxtral-mini-latest',
+ options: {
+ options: [
+ { label: 'voxtral-mini-latest', value: 'voxtral-mini-latest' },
+ { label: 'voxtral-mini-2507', value: 'voxtral-mini-2507' },
+ ],
+ },
+ }),
+ file: Property.File({
+ displayName: 'Audio File',
+ description: 'The audio file to transcribe. Leave empty if you use Audio URL or File ID.',
+ required: false,
+ }),
+ file_url: Property.ShortText({
+ displayName: 'Audio URL',
+ description: 'Public URL of the audio file.',
+ required: false,
+ }),
+ file_id: Property.ShortText({
+ displayName: 'File ID',
+ description: 'UUID of an audio file already uploaded to Mistral (see List Files).',
+ required: false,
+ }),
+ language: Property.ShortText({
+ displayName: 'Language',
+ description: 'Two-letter language code of the audio, e.g. en or fr. Leave empty to auto-detect.',
+ required: false,
+ }),
+ diarize: Property.Checkbox({
+ displayName: 'Identify Speakers',
+ description: 'Label which speaker said each segment.',
+ required: false,
+ defaultValue: false,
+ }),
+ timestamp_granularity: Property.StaticDropdown({
+ displayName: 'Timestamps',
+ required: false,
+ options: {
+ options: [
+ { label: 'Segment', value: 'segment' },
+ { label: 'Word', value: 'word' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const { model, file, file_url, file_id, language, diarize, timestamp_granularity } = context.propsValue;
+ const sources = [file, file_url, file_id].filter((source) => source !== undefined && source !== null && source !== '');
+ if (sources.length !== 1) {
+ throw new Error('Provide exactly one of Audio File, Audio URL or File ID.');
+ }
+ const form = new FormData();
+ form.append('model', model);
+ if (file) {
+ form.append('file', Buffer.from(file.data), file.filename);
+ }
+ if (file_url) {
+ form.append('file_url', file_url);
+ }
+ if (file_id) {
+ form.append('file_id', file_id);
+ }
+ if (language) {
+ form.append('language', language);
+ }
+ if (diarize) {
+ form.append('diarize', 'true');
+ }
+ if (timestamp_granularity) {
+ form.append('timestamp_granularities', timestamp_granularity);
+ }
+ const response = await mistralApi.call<TranscriptionResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/audio/transcriptions',
+ headers: form.getHeaders(),
+ body: form,
+ timeout: 600000,
+ });
+ return {
+ model: response.model,
+ text: response.text,
+ language: response.language ?? null,
+ segments: (response.segments ?? []).map((segment) => ({
+ text: segment.text,
+ start: segment.start,
+ end: segment.end,
+ speaker_id: segment.speaker_id ?? null,
+ })),
+ prompt_audio_seconds: response.usage?.prompt_audio_seconds ?? null,
+ total_tokens: response.usage?.total_tokens ?? null,
+ };
+ },
+});
+
+type TranscriptionResponse = {
+ model: string;
+ text: string;
+ language: string | null;
+ segments?: { text: string; start: number; end: number; speaker_id?: string | null }[];
+ usage?: { prompt_audio_seconds?: number | null; total_tokens?: number };
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/update-agent.ts b/packages/pieces/community/mistral-ai/src/lib/actions/update-agent.ts
new file mode 100644
index 00000000000..2113f07000e
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/update-agent.ts
@@ -0,0 +1,86 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { AgentTool, agentUtils, MistralAgent } from '../common/agents';
+import { MistralAuthValue } from '../common/request';
+import { agentOutputSchema } from '../output-schemas';
+
+export const updateAgent = createAction({
+ auth: mistralAuth,
+ name: 'update_agent',
+ classification: 'WRITE',
+ displayName: 'Update Agent',
+ description: 'Change a Mistral agent’s name, model, instructions or tools (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Updates a Mistral agent (Beta) by agent id; only the fields you pass change and the rest are kept. Built-in tools and document libraries are replaced independently: passing one keeps the other as it was. Tools cannot be cleared here. Each update creates a new agent version. Get the id from List Agents. Idempotent: sending the same values again leaves the same configuration.',
+ idempotent: true,
+ },
+ outputSchema: agentOutputSchema,
+ props: {
+ agent_id: Property.ShortText({
+ displayName: 'Agent ID',
+ description: 'The agent id (usually starts with ag_), from List Agents.',
+ required: true,
+ }),
+ name: Property.ShortText({ displayName: 'Name', required: false }),
+ model: Property.ShortText({ displayName: 'Model', required: false }),
+ instructions: Property.LongText({ displayName: 'Instructions', required: false }),
+ description: Property.ShortText({ displayName: 'Description', required: false }),
+ ...agentUtils.toolsProps(),
+ temperature: Property.Number({ displayName: 'Temperature', required: false }),
+ },
+ async run(context) {
+ const { agent_id, name, model, instructions, description, built_in_tools, library_ids, temperature } = context.propsValue;
+ const body = mistralApi.compact({
+ name,
+ model,
+ instructions,
+ description,
+ tools: await resolveTools({
+ auth: context.auth,
+ agentId: agent_id,
+ builtInTools: mistralApi.toStringArray(built_in_tools),
+ libraryIds: mistralApi.toStringArray(library_ids),
+ }),
+ completion_args: temperature === undefined || temperature === null ? undefined : { temperature },
+ });
+ if (Object.keys(body).length === 0) {
+ throw new Error('Provide at least one field to update.');
+ }
+ const agent = await mistralApi.call<MistralAgent>({
+ auth: context.auth,
+ method: HttpMethod.PATCH,
+ path: `/agents/${encodeURIComponent(agent_id)}`,
+ body,
+ });
+ return agentUtils.formatAgent(agent);
+ },
+});
+
+async function resolveTools({ auth, agentId, builtInTools, libraryIds }: ResolveToolsParams): Promise<AgentTool[] | undefined> {
+ if (builtInTools.length === 0 && libraryIds.length === 0) {
+ return undefined;
+ }
+ const updated = agentUtils.buildTools({ builtInTools, libraryIds }) ?? [];
+ if (builtInTools.length > 0 && libraryIds.length > 0) {
+ return updated;
+ }
+ const current = await mistralApi.call<MistralAgent>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/agents/${encodeURIComponent(agentId)}`,
+ });
+ const keepLibraries = libraryIds.length === 0;
+ const kept = (current.tools ?? []).filter((tool) => (tool.type === 'document_library') === keepLibraries);
+ return [...updated, ...kept];
+}
+
+type ResolveToolsParams = {
+ auth: MistralAuthValue;
+ agentId: string;
+ builtInTools: string[];
+ libraryIds: string[];
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/update-library-document.ts b/packages/pieces/community/mistral-ai/src/lib/actions/update-library-document.ts
new file mode 100644
index 00000000000..402a544c70e
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/update-library-document.ts
@@ -0,0 +1,54 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralDocument } from '../common/libraries';
+import { documentOutputSchema } from '../output-schemas';
+
+export const updateLibraryDocument = createAction({
+ auth: mistralAuth,
+ name: 'update_library_document',
+ classification: 'WRITE',
+ displayName: 'Update Library Document',
+ description: 'Rename a library document, set its attributes or an expiry date (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Updates a library document’s name, custom attributes and/or automatic-deletion date (Beta); a field you leave empty keeps its current value, but passing attributes replaces the whole attribute set. It does not change the file content. Idempotent: sending the same values again leaves the same document.',
+ idempotent: true,
+ },
+ outputSchema: documentOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ document_id: libraryUtils.documentIdProp(),
+ name: Property.ShortText({ displayName: 'Name', required: false }),
+ attributes: Property.Json({
+ displayName: 'Attributes',
+ description: 'Custom key-value attributes as a JSON object. Replaces the existing attributes.',
+ required: false,
+ }),
+ expires_at: Property.DateTime({
+ displayName: 'Delete After',
+ description: 'The document is deleted automatically after this date.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { library_id, document_id, name, attributes, expires_at } = context.propsValue;
+ const body = mistralApi.compact({
+ name,
+ attributes: mistralApi.parseJsonInput({ value: attributes, fieldName: 'Attributes' }),
+ expires_at,
+ });
+ if (Object.keys(body).length === 0) {
+ throw new Error('Provide at least one field to update.');
+ }
+ const document = await mistralApi.call<MistralDocument>({
+ auth: context.auth,
+ method: HttpMethod.PATCH,
+ path: libraryUtils.documentPath({ libraryId: library_id, documentId: document_id }),
+ body,
+ });
+ return libraryUtils.formatDocument(document);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/update-library.ts b/packages/pieces/community/mistral-ai/src/lib/actions/update-library.ts
new file mode 100644
index 00000000000..bec3b5df8f5
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/update-library.ts
@@ -0,0 +1,40 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralLibrary } from '../common/libraries';
+import { libraryOutputSchema } from '../output-schemas';
+
+export const updateLibrary = createAction({
+ auth: mistralAuth,
+ name: 'update_library',
+ classification: 'WRITE',
+ displayName: 'Update Library',
+ description: 'Rename a document library or change its description (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Updates a document library’s name and/or description (Beta) by UUID; a field you leave empty keeps its current value. Idempotent: sending the same values again leaves the same library.',
+ idempotent: true,
+ },
+ outputSchema: libraryOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ name: Property.ShortText({ displayName: 'Name', required: false }),
+ description: Property.LongText({ displayName: 'Description', required: false }),
+ },
+ async run(context) {
+ const { library_id, name, description } = context.propsValue;
+ const body = mistralApi.compact({ name, description });
+ if (Object.keys(body).length === 0) {
+ throw new Error('Provide a name or a description to update.');
+ }
+ const library = await mistralApi.call<MistralLibrary>({
+ auth: context.auth,
+ method: HttpMethod.PATCH,
+ path: `/libraries/${encodeURIComponent(library_id)}`,
+ body,
+ });
+ return libraryUtils.formatLibrary(library);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/upload-file.ts b/packages/pieces/community/mistral-ai/src/lib/actions/upload-file.ts
index 61217ac39b4..6fe6824bde0 100644
--- a/packages/pieces/community/mistral-ai/src/lib/actions/upload-file.ts
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/upload-file.ts
@@ -4,6 +4,7 @@ import { mistralAuth } from '../common/auth';
import FormData from 'form-data';
import { parseMistralError } from '../common/props';
import { mistralRequest } from '../common/request';
+import { uploadFileOutputSchema } from '../output-schemas';
const SUPPORTED_PURPOSES = ['fine-tune', 'batch', 'ocr'];
const MAX_FILE_SIZE_BYTES = 512 * 1024 * 1024;
@@ -33,6 +34,7 @@ export const uploadFile = createAction({
displayName: 'Upload File',
description: 'Upload a file to Mistral AI (e.g., for fine-tuning or context storage).',
aiMetadata: { description: 'Stores a file in the connected Mistral account and returns its file id, tagged with a purpose of fine-tune, batch, or ocr that decides what the id may later be used for. Run it before Run OCR whenever the document is a step attachment rather than a public URL: upload with purpose=ocr and feed the returned id into that action. Rejects files above 512MB or with an extension outside jsonl, txt, csv, pdf, docx, png, jpg, jpeg, mp3, mp4; not idempotent: each call stores another copy and returns a new id.', idempotent: false },
+ outputSchema: uploadFileOutputSchema,
props: {
file: Property.File({
displayName: 'File',
diff --git a/packages/pieces/community/mistral-ai/src/lib/actions/upload-library-document.ts b/packages/pieces/community/mistral-ai/src/lib/actions/upload-library-document.ts
new file mode 100644
index 00000000000..46ea154e14a
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/actions/upload-library-document.ts
@@ -0,0 +1,44 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import FormData from 'form-data';
+import { mistralAuth } from '../common/auth';
+import { mistralApi } from '../common/client';
+import { libraryUtils, MistralDocument } from '../common/libraries';
+import { documentOutputSchema } from '../output-schemas';
+
+export const uploadLibraryDocument = createAction({
+ auth: mistralAuth,
+ name: 'upload_library_document',
+ classification: 'WRITE',
+ displayName: 'Upload Library Document',
+ description: 'Add a document to a library (Beta).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Uploads a file into a Mistral document library (Beta) and returns the new document’s UUID and processing status. Processing is asynchronous: poll Get Document Status until it is done before relying on it in an agent or reading Get Document Text Content. Not idempotent: each call adds another document.',
+ idempotent: false,
+ },
+ outputSchema: documentOutputSchema,
+ props: {
+ library_id: libraryUtils.libraryIdProp(),
+ file: Property.File({
+ displayName: 'File',
+ description: 'The document to add, e.g. a PDF, DOCX or text file.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { library_id, file } = context.propsValue;
+ const form = new FormData();
+ form.append('file', Buffer.from(file.data), file.filename);
+ const document = await mistralApi.call<MistralDocument>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/libraries/${encodeURIComponent(library_id)}/documents`,
+ headers: form.getHeaders(),
+ body: form,
+ timeout: 300000,
+ });
+ return libraryUtils.formatDocument(document);
+ },
+});
diff --git a/packages/pieces/community/mistral-ai/src/lib/common/agents.ts b/packages/pieces/community/mistral-ai/src/lib/common/agents.ts
new file mode 100644
index 00000000000..9f0b7c22f77
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/common/agents.ts
@@ -0,0 +1,69 @@
+import { Property } from '@activepieces/pieces-framework';
+
+function buildTools({ builtInTools, libraryIds }: { builtInTools: string[]; libraryIds: string[] }): AgentTool[] | undefined {
+ const tools: AgentTool[] = [
+ ...builtInTools.map((type) => ({ type })),
+ ...(libraryIds.length > 0 ? [{ type: 'document_library', library_ids: libraryIds }] : []),
+ ];
+ return tools.length > 0 ? tools : undefined;
+}
+
+function formatAgent(agent: MistralAgent) {
+ return {
+ id: agent.id,
+ name: agent.name,
+ description: agent.description ?? null,
+ model: agent.model,
+ instructions: agent.instructions ?? null,
+ tools: (agent.tools ?? []).map((tool) => tool.type),
+ library_ids: (agent.tools ?? []).flatMap((tool) => tool.library_ids ?? []),
+ temperature: agent.completion_args?.temperature ?? null,
+ version: agent.version,
+ versions: agent.versions ?? [],
+ source: agent.source ?? null,
+ created_at: agent.created_at,
+ updated_at: agent.updated_at,
+ };
+}
+
+function toolsProps() {
+ return {
+ built_in_tools: Property.StaticMultiSelectDropdown({
+ displayName: 'Built-in Tools',
+ description: 'Mistral-hosted tools the agent may use.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Web Search', value: 'web_search' },
+ { label: 'Web Search (Premium)', value: 'web_search_premium' },
+ { label: 'Code Interpreter', value: 'code_interpreter' },
+ { label: 'Image Generation', value: 'image_generation' },
+ ],
+ },
+ }),
+ library_ids: Property.Array({
+ displayName: 'Document Library IDs',
+ description: 'Library UUIDs (from List Libraries) the agent can search for answers.',
+ required: false,
+ }),
+ };
+}
+
+export const agentUtils = { buildTools, formatAgent, toolsProps };
+
+export type AgentTool = { type: string; library_ids?: string[] };
+
+export type MistralAgent = {
+ id: string;
+ name: string;
+ description?: string | null;
+ model: string;
+ instructions?: string | null;
+ tools?: AgentTool[];
+ completion_args?: { temperature?: number | null };
+ version: number;
+ versions?: number[];
+ source?: string;
+ created_at: string;
+ updated_at: string;
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/common/batch.ts b/packages/pieces/community/mistral-ai/src/lib/common/batch.ts
new file mode 100644
index 00000000000..1e8af00295d
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/common/batch.ts
@@ -0,0 +1,79 @@
+import { Property } from '@activepieces/pieces-framework';
+import { fileUtils } from './files';
+
+function formatJob(job: MistralBatchJob) {
+ return {
+ id: job.id,
+ status: job.status,
+ endpoint: job.endpoint,
+ model: job.model ?? null,
+ agent_id: job.agent_id ?? null,
+ input_files: job.input_files ?? [],
+ output_file: job.output_file ?? null,
+ error_file: job.error_file ?? null,
+ total_requests: job.total_requests,
+ completed_requests: job.completed_requests,
+ succeeded_requests: job.succeeded_requests,
+ failed_requests: job.failed_requests,
+ errors: (job.errors ?? []).map((error) => ({ message: error.message, count: error.count ?? null })),
+ metadata: job.metadata ?? null,
+ outputs: job.outputs ?? null,
+ created_at: fileUtils.toIso(job.created_at),
+ started_at: fileUtils.toIso(job.started_at),
+ completed_at: fileUtils.toIso(job.completed_at),
+ };
+}
+
+function jobIdProp() {
+ return Property.ShortText({
+ displayName: 'Batch Job ID',
+ description: 'The batch job UUID, from Create Batch Job or List Batch Jobs.',
+ required: true,
+ });
+}
+
+export const batchUtils = { formatJob, jobIdProp };
+
+export const BATCH_STATUS_OPTIONS = [
+ { label: 'Queued', value: 'QUEUED' },
+ { label: 'Running', value: 'RUNNING' },
+ { label: 'Success', value: 'SUCCESS' },
+ { label: 'Failed', value: 'FAILED' },
+ { label: 'Timeout Exceeded', value: 'TIMEOUT_EXCEEDED' },
+ { label: 'Cancellation Requested', value: 'CANCELLATION_REQUESTED' },
+ { label: 'Cancelled', value: 'CANCELLED' },
+];
+
+export const BATCH_ENDPOINT_OPTIONS = [
+ { label: 'Chat Completions', value: '/v1/chat/completions' },
+ { label: 'Embeddings', value: '/v1/embeddings' },
+ { label: 'FIM Completions', value: '/v1/fim/completions' },
+ { label: 'Moderations', value: '/v1/moderations' },
+ { label: 'Chat Moderations', value: '/v1/chat/moderations' },
+ { label: 'OCR', value: '/v1/ocr' },
+ { label: 'Classifications', value: '/v1/classifications' },
+ { label: 'Chat Classifications', value: '/v1/chat/classifications' },
+ { label: 'Conversations', value: '/v1/conversations' },
+ { label: 'Audio Transcriptions', value: '/v1/audio/transcriptions' },
+];
+
+export type MistralBatchJob = {
+ id: string;
+ status: string;
+ endpoint: string;
+ model?: string | null;
+ agent_id?: string | null;
+ input_files?: string[];
+ output_file?: string | null;
+ error_file?: string | null;
+ errors?: { message: string; count?: number }[];
+ outputs?: Record<string, unknown>[] | null;
+ metadata?: Record<string, unknown> | null;
+ total_requests: number;
+ completed_requests: number;
+ succeeded_requests: number;
+ failed_requests: number;
+ created_at: number;
+ started_at?: number | null;
+ completed_at?: number | null;
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/common/client.ts b/packages/pieces/community/mistral-ai/src/lib/common/client.ts
new file mode 100644
index 00000000000..9f70586375e
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/common/client.ts
@@ -0,0 +1,166 @@
+import { HttpError, HttpMethod, httpClient } from '@activepieces/pieces-common';
+import { isNil } from '@activepieces/pieces-framework';
+import { Stream } from 'stream';
+import { MistralAuthValue, mistralRequest } from './request';
+
+async function call<T>({ auth, method, path, body, queryParams, headers, timeout, responseType }: MistralCallParams): Promise<T> {
+ const config = mistralRequest.getConfig(auth);
+ for (let attempt = 0; ; attempt++) {
+ try {
+ const response = await httpClient.sendRequest<T>({
+ method,
+ url: `${config.baseUrl}${path}`,
+ headers: { ...config.headers, ...headers },
+ body,
+ queryParams: toQueryParams(queryParams),
+ timeout,
+ responseType,
+ });
+ return response.body;
+ } catch (e) {
+ if (isRateLimited(e) && isRetrySafe({ method, path, body }) && attempt < MAX_RATE_LIMIT_RETRIES) {
+ await new Promise((resolve) => setTimeout(resolve, 1000 * 2 ** attempt));
+ continue;
+ }
+ throw new Error(describeError({ error: e, isGateway: config.baseUrl.includes(GATEWAY_HOST) }));
+ }
+ }
+}
+
+function parseJsonInput({ value, fieldName }: { value: unknown; fieldName: string }): unknown {
+ if (isNil(value) || value === '') {
+ return undefined;
+ }
+ if (typeof value !== 'string') {
+ return value;
+ }
+ try {
+ return JSON.parse(value);
+ } catch {
+ throw new Error(`${fieldName} must be valid JSON.`);
+ }
+}
+
+function toStringArray(value: unknown): string[] {
+ if (!Array.isArray(value)) {
+ return [];
+ }
+ return value.map((item) => String(item).trim()).filter((item) => item.length > 0);
+}
+
+function contentToText(content: unknown): string | null {
+ if (isNil(content)) {
+ return null;
+ }
+ if (typeof content === 'string') {
+ return content;
+ }
+ if (Array.isArray(content)) {
+ return content.map((chunk) => (isRecord(chunk) && typeof chunk['text'] === 'string' ? chunk['text'] : '')).join('');
+ }
+ return null;
+}
+
+function compact(obj: Record<string, unknown>): Record<string, unknown> {
+ return Object.fromEntries(Object.entries(obj).filter(([, value]) => !isNil(value) && value !== ''));
+}
+
+function isRecord(value: unknown): value is Record<string, unknown> {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
+}
+
+export const mistralApi = { call, parseJsonInput, toStringArray, contentToText, compact, isRecord };
+
+function toQueryParams(params: MistralCallParams['queryParams']): Record<string, string> | undefined {
+ if (isNil(params)) {
+ return undefined;
+ }
+ return Object.fromEntries(
+ Object.entries(params)
+ .filter(([, value]) => !isNil(value) && value !== '')
+ .map(([key, value]) => [key, String(value)]),
+ );
+}
+
+function isRateLimited(error: unknown): boolean {
+ return error instanceof HttpError && error.response.status === 429;
+}
+
+function isRetrySafe({ method, path, body }: { method: HttpMethod; path: string; body: unknown }): boolean {
+ if (body instanceof Stream) {
+ return false;
+ }
+ return method !== HttpMethod.POST || STATELESS_POST_PATHS.includes(path);
+}
+
+function describeError({ error, isGateway }: { error: unknown; isGateway: boolean }): string {
+ if (!(error instanceof HttpError)) {
+ return error instanceof Error ? error.message : String(error);
+ }
+ const status = error.response.status;
+ const detail = extractDetail(error.response.body);
+ const suffix = detail ? `: ${detail}` : '';
+ switch (status) {
+ case 401:
+ return 'Mistral rejected the API key (401). Check the connection.';
+ case 403:
+ return `Mistral denied access to this resource (403)${suffix}`;
+ case 404:
+ return isGateway
+ ? `Not found (404). The id may be wrong, or this endpoint is not passed through your Cloudflare AI Gateway${suffix}`
+ : `Not found (404). Check the id you passed${suffix}`;
+ case 422:
+ return `Mistral rejected the request as invalid (422)${suffix}`;
+ case 429:
+ return `Mistral rate limit or capacity limit reached (429). Wait and try again${suffix}`;
+ default:
+ return `Mistral request failed (${status})${suffix}`;
+ }
+}
+
+function extractDetail(body: unknown): string | null {
+ if (isNil(body)) {
+ return null;
+ }
+ if (typeof body === 'string') {
+ return body.slice(0, 500);
+ }
+ if (!isRecord(body)) {
+ return String(body);
+ }
+ if (typeof body['message'] === 'string') {
+ return body['message'];
+ }
+ const detail = body['detail'];
+ if (typeof detail === 'string') {
+ return detail;
+ }
+ if (Array.isArray(detail)) {
+ return detail.map(formatValidationItem).join('; ');
+ }
+ return JSON.stringify(body).slice(0, 500);
+}
+
+function formatValidationItem(item: unknown): string {
+ if (!isRecord(item)) {
+ return String(item);
+ }
+ const location = Array.isArray(item['loc']) ? item['loc'].join('.') : '';
+ const message = typeof item['msg'] === 'string' ? item['msg'] : '';
+ return `${location}: ${message}`;
+}
+
+const GATEWAY_HOST = 'gateway.ai.cloudflare.com';
+const MAX_RATE_LIMIT_RETRIES = 3;
+const STATELESS_POST_PATHS = ['/chat/completions', '/fim/completions', '/moderations', '/chat/moderations', '/audio/speech'];
+
+type MistralCallParams = {
+ auth: MistralAuthValue;
+ method: HttpMethod;
+ path: string;
+ body?: unknown;
+ queryParams?: Record<string, string | number | boolean | null | undefined>;
+ headers?: Record<string, string>;
+ timeout?: number;
+ responseType?: 'arraybuffer' | 'json';
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/common/conversations.ts b/packages/pieces/community/mistral-ai/src/lib/common/conversations.ts
new file mode 100644
index 00000000000..4d2c2381213
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/common/conversations.ts
@@ -0,0 +1,88 @@
+import { Property } from '@activepieces/pieces-framework';
+import { mistralApi } from './client';
+
+function formatEntry(entry: ConversationEntry) {
+ return {
+ id: entry.id ?? null,
+ type: entry.type ?? null,
+ role: entry.role ?? null,
+ content: mistralApi.contentToText(entry.content),
+ chunks: Array.isArray(entry.content) ? entry.content.filter((chunk) => !(mistralApi.isRecord(chunk) && chunk['type'] === 'text')) : [],
+ name: entry.name ?? null,
+ arguments: entry.arguments ?? null,
+ agent_id: entry.agent_id ?? null,
+ model: entry.model ?? null,
+ created_at: entry.created_at ?? null,
+ };
+}
+
+function formatResponse(response: ConversationResponse) {
+ const outputs = response.outputs.map(formatEntry);
+ const reply = outputs
+ .filter((output) => output.type === 'message.output')
+ .map((output) => output.content ?? '')
+ .join('\n')
+ .trim();
+ return {
+ conversation_id: response.conversation_id,
+ reply: reply.length > 0 ? reply : null,
+ outputs,
+ prompt_tokens: response.usage?.prompt_tokens ?? null,
+ completion_tokens: response.usage?.completion_tokens ?? null,
+ total_tokens: response.usage?.total_tokens ?? null,
+ };
+}
+
+function formatConversation(conversation: MistralConversation) {
+ return {
+ id: conversation.id,
+ name: conversation.name ?? null,
+ description: conversation.description ?? null,
+ agent_id: conversation.agent_id ?? null,
+ agent_version: conversation.agent_version ?? null,
+ model: conversation.model ?? null,
+ instructions: conversation.instructions ?? null,
+ created_at: conversation.created_at,
+ updated_at: conversation.updated_at,
+ };
+}
+
+function conversationIdProp() {
+ return Property.ShortText({
+ displayName: 'Conversation ID',
+ description: 'The conversation id (usually starts with conv_), from Start Conversation or List Conversations.',
+ required: true,
+ });
+}
+
+export const conversationUtils = { formatEntry, formatResponse, formatConversation, conversationIdProp };
+
+export type ConversationEntry = {
+ id?: string;
+ type?: string;
+ role?: string;
+ content?: unknown;
+ name?: string;
+ arguments?: string;
+ agent_id?: string | null;
+ model?: string | null;
+ created_at?: string;
+};
+
+export type ConversationResponse = {
+ conversation_id: string;
+ outputs: ConversationEntry[];
+ usage?: { prompt_tokens?: number; completion_tokens?: number; total_tokens?: number };
+};
+
+export type MistralConversation = {
+ id: string;
+ name?: string | null;
+ description?: string | null;
+ agent_id?: string;
+ agent_version?: number | string | null;
+ model?: string;
+ instructions?: string | null;
+ created_at: string;
+ updated_at: string;
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/common/files.ts b/packages/pieces/community/mistral-ai/src/lib/common/files.ts
new file mode 100644
index 00000000000..b03e4285491
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/common/files.ts
@@ -0,0 +1,42 @@
+function formatFile(file: MistralFile) {
+ return {
+ id: file.id,
+ filename: file.filename,
+ purpose: file.purpose,
+ bytes: file.bytes,
+ mimetype: file.mimetype ?? null,
+ source: file.source ?? null,
+ sample_type: file.sample_type ?? null,
+ num_lines: file.num_lines ?? null,
+ created_at: toIso(file.created_at),
+ expires_at: toIso(file.expires_at),
+ };
+}
+
+function toIso(seconds: number | null | undefined): string | null {
+ if (seconds === null || seconds === undefined) {
+ return null;
+ }
+ return new Date(seconds * 1000).toISOString();
+}
+
+export const fileUtils = { formatFile, toIso };
+
+export const FILE_PURPOSE_OPTIONS = [
+ { label: 'OCR', value: 'ocr' },
+ { label: 'Batch', value: 'batch' },
+ { label: 'Fine-tune', value: 'fine-tune' },
+];
+
+export type MistralFile = {
+ id: string;
+ filename: string;
+ purpose: string;
+ bytes: number;
+ created_at: number;
+ mimetype?: string | null;
+ source?: string;
+ sample_type?: string;
+ num_lines?: number | null;
+ expires_at?: number | null;
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/common/libraries.ts b/packages/pieces/community/mistral-ai/src/lib/common/libraries.ts
new file mode 100644
index 00000000000..6b605e9bd98
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/common/libraries.ts
@@ -0,0 +1,87 @@
+import { Property } from '@activepieces/pieces-framework';
+
+function formatLibrary(library: MistralLibrary) {
+ return {
+ id: library.id,
+ name: library.name,
+ description: library.description ?? null,
+ generated_description: library.generated_description ?? null,
+ owner_type: library.owner_type ?? null,
+ owner_id: library.owner_id ?? null,
+ nb_documents: library.nb_documents ?? null,
+ total_size: library.total_size ?? null,
+ chunk_size: library.chunk_size ?? null,
+ created_at: library.created_at,
+ updated_at: library.updated_at,
+ };
+}
+
+function formatDocument(document: MistralDocument) {
+ return {
+ id: document.id,
+ library_id: document.library_id,
+ name: document.name,
+ mime_type: document.mime_type ?? null,
+ extension: document.extension ?? null,
+ size: document.size ?? null,
+ number_of_pages: document.number_of_pages ?? null,
+ summary: document.summary ?? null,
+ process_status: document.process_status ?? null,
+ attributes: document.attributes ?? null,
+ expires_at: document.expires_at ?? null,
+ created_at: document.created_at,
+ last_processed_at: document.last_processed_at ?? null,
+ };
+}
+
+function libraryIdProp() {
+ return Property.ShortText({
+ displayName: 'Library ID',
+ description: 'The library UUID, from List Libraries or Create Library.',
+ required: true,
+ });
+}
+
+function documentIdProp() {
+ return Property.ShortText({
+ displayName: 'Document ID',
+ description: 'The document UUID, from List Library Documents or Upload Library Document.',
+ required: true,
+ });
+}
+
+function documentPath({ libraryId, documentId }: { libraryId: string; documentId: string }): string {
+ return `/libraries/${encodeURIComponent(libraryId)}/documents/${encodeURIComponent(documentId)}`;
+}
+
+export const libraryUtils = { formatLibrary, formatDocument, libraryIdProp, documentIdProp, documentPath };
+
+export type MistralLibrary = {
+ id: string;
+ name: string;
+ description?: string | null;
+ generated_description?: string | null;
+ owner_type?: string;
+ owner_id?: string | null;
+ nb_documents?: number;
+ total_size?: number;
+ chunk_size?: number | null;
+ created_at: string;
+ updated_at: string;
+};
+
+export type MistralDocument = {
+ id: string;
+ library_id: string;
+ name: string;
+ mime_type?: string | null;
+ extension?: string | null;
+ size?: number | null;
+ number_of_pages?: number | null;
+ summary?: string | null;
+ process_status?: string;
+ attributes?: Record<string, unknown> | null;
+ expires_at?: string | null;
+ created_at: string;
+ last_processed_at?: string | null;
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/common/moderation.ts b/packages/pieces/community/mistral-ai/src/lib/common/moderation.ts
new file mode 100644
index 00000000000..60d9336d21c
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/common/moderation.ts
@@ -0,0 +1,28 @@
+function formatResponse({ response, inputs }: { response: ModerationResponse; inputs: string[] }) {
+ const results = response.results.map((result, index) => {
+ const flagged = Object.entries(result.categories ?? {})
+ .filter(([, value]) => value === true)
+ .map(([category]) => category);
+ return {
+ input: inputs[index] ?? null,
+ flagged: flagged.length > 0,
+ flagged_categories: flagged,
+ categories: result.categories ?? {},
+ category_scores: result.category_scores ?? {},
+ };
+ });
+ return {
+ id: response.id,
+ model: response.model,
+ any_flagged: results.some((result) => result.flagged),
+ results,
+ };
+}
+
+export const moderationUtils = { formatResponse };
+
+export type ModerationResponse = {
+ id: string;
+ model: string;
+ results: { categories?: Record<string, boolean>; category_scores?: Record<string, number> }[];
+};
diff --git a/packages/pieces/community/mistral-ai/src/lib/output-schemas.ts b/packages/pieces/community/mistral-ai/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..6dc6d3e5f3b
--- /dev/null
+++ b/packages/pieces/community/mistral-ai/src/lib/output-schemas.ts
@@ -0,0 +1,406 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const tokenUsageFields: OutputSchema['fields'] = [
+ { key: 'prompt_tokens', label: 'Prompt Tokens', format: 'number' },
+ { key: 'completion_tokens', label: 'Completion Tokens', format: 'number' },
+ { key: 'total_tokens', label: 'Total Tokens', format: 'number' },
+];
+
+const moderationFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Moderation ID' },
+ { key: 'model', label: 'Model' },
+ { key: 'any_flagged', label: 'Any Flagged', format: 'boolean' },
+ {
+ key: 'results',
+ label: 'Results',
+ labelKey: 'input',
+ listItems: [
+ { key: 'input', label: 'Input' },
+ { key: 'flagged', label: 'Flagged', format: 'boolean' },
+ { key: 'flagged_categories', label: 'Flagged Categories' },
+ { key: 'categories', label: 'Categories', dynamicKey: true },
+ { key: 'category_scores', label: 'Category Scores', dynamicKey: true },
+ ],
+ },
+];
+
+const modelFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Model ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'type', label: 'Type' },
+ { key: 'owned_by', label: 'Owned By' },
+ { key: 'max_context_length', label: 'Max Context Length', format: 'number' },
+ { key: 'aliases', label: 'Aliases' },
+ { key: 'deprecation', label: 'Deprecation Date', format: 'datetime' },
+ { key: 'default_model_temperature', label: 'Default Temperature', format: 'number' },
+ { key: 'capabilities', label: 'Capabilities', dynamicKey: true },
+];
+
+const fileFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'File ID' },
+ { key: 'filename', label: 'File Name' },
+ { key: 'purpose', label: 'Purpose' },
+ { key: 'bytes', label: 'Size', format: 'filesize' },
+ { key: 'mimetype', label: 'MIME Type' },
+ { key: 'source', label: 'Source' },
+ { key: 'sample_type', label: 'Sample Type' },
+ { key: 'num_lines', label: 'Number of Lines', format: 'number' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'expires_at', label: 'Expires At', format: 'datetime' },
+];
+
+const agentFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Agent ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'model', label: 'Model' },
+ { key: 'instructions', label: 'Instructions' },
+ { key: 'tools', label: 'Tools' },
+ { key: 'library_ids', label: 'Library IDs' },
+ { key: 'temperature', label: 'Temperature', format: 'number' },
+ { key: 'version', label: 'Version', format: 'number' },
+ { key: 'source', label: 'Source' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const conversationEntryFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Entry ID' },
+ { key: 'type', label: 'Type' },
+ { key: 'role', label: 'Role' },
+ { key: 'content', label: 'Content' },
+ { key: 'chunks', label: 'Files & References' },
+ { key: 'name', label: 'Tool Name' },
+ { key: 'arguments', label: 'Tool Arguments' },
+ { key: 'agent_id', label: 'Agent ID' },
+ { key: 'model', label: 'Model' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+];
+
+const conversationReplyFields: OutputSchema['fields'] = [
+ { key: 'conversation_id', label: 'Conversation ID' },
+ { key: 'reply', label: 'Reply' },
+ { key: 'outputs', label: 'Outputs', labelKey: 'type', listItems: conversationEntryFields },
+ ...tokenUsageFields,
+];
+
+const conversationFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Conversation ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'agent_id', label: 'Agent ID' },
+ { key: 'agent_version', label: 'Agent Version' },
+ { key: 'model', label: 'Model' },
+ { key: 'instructions', label: 'Instructions' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const libraryFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Library ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'generated_description', label: 'Generated Description' },
+ { key: 'owner_type', label: 'Owner Type' },
+ { key: 'owner_id', label: 'Owner ID' },
+ { key: 'nb_documents', label: 'Number of Documents', format: 'number' },
+ { key: 'total_size', label: 'Total Size', format: 'filesize' },
+ { key: 'chunk_size', label: 'Chunk Size', format: 'number' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const documentFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Document ID' },
+ { key: 'library_id', label: 'Library ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'mime_type', label: 'MIME Type' },
+ { key: 'extension', label: 'Extension' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ { key: 'number_of_pages', label: 'Number of Pages', format: 'number' },
+ { key: 'summary', label: 'Summary' },
+ { key: 'process_status', label: 'Processing Status' },
+ { key: 'attributes', label: 'Attributes', dynamicKey: true },
+ { key: 'expires_at', label: 'Delete After', format: 'datetime' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'last_processed_at', label: 'Last Processed At', format: 'datetime' },
+];
+
+const generatedFileFields: OutputSchema['fields'] = [
+ { key: 'file', label: 'File', format: 'url' },
+ { key: 'file_name', label: 'File Name' },
+ { key: 'size_bytes', label: 'Size', format: 'filesize' },
+];
+
+const batchJobFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Batch Job ID' },
+ { key: 'status', label: 'Status' },
+ { key: 'endpoint', label: 'Endpoint' },
+ { key: 'model', label: 'Model' },
+ { key: 'agent_id', label: 'Agent ID' },
+ { key: 'input_files', label: 'Input File IDs' },
+ { key: 'output_file', label: 'Output File ID' },
+ { key: 'error_file', label: 'Error File ID' },
+ { key: 'total_requests', label: 'Total Requests', format: 'number' },
+ { key: 'completed_requests', label: 'Completed Requests', format: 'number' },
+ { key: 'succeeded_requests', label: 'Succeeded Requests', format: 'number' },
+ { key: 'failed_requests', label: 'Failed Requests', format: 'number' },
+ {
+ key: 'errors',
+ label: 'Errors',
+ labelKey: 'message',
+ listItems: [
+ { key: 'message', label: 'Message' },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+ },
+ { key: 'metadata', label: 'Metadata', dynamicKey: true },
+ { key: 'outputs', label: 'Inline Outputs' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'started_at', label: 'Started At', format: 'datetime' },
+ { key: 'completed_at', label: 'Completed At', format: 'datetime' },
+];
+
+export const generateChatCompletionOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Completion ID' },
+ { key: 'model', label: 'Model' },
+ { key: 'content', label: 'Reply' },
+ { key: 'finish_reason', label: 'Finish Reason' },
+ ...tokenUsageFields,
+ ],
+};
+
+export const batchJobOutputSchema: OutputSchema = { fields: batchJobFields };
+
+export const listBatchJobsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'jobs', label: 'Batch Jobs', labelKey: 'id', listItems: batchJobFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'total', label: 'Total', format: 'number' },
+ ],
+};
+
+export const completeCodeFimOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Completion ID' },
+ { key: 'model', label: 'Model' },
+ { key: 'completion', label: 'Completion' },
+ { key: 'finish_reason', label: 'Finish Reason' },
+ ...tokenUsageFields,
+ ],
+};
+
+export const transcribeAudioOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'text', label: 'Transcript' },
+ { key: 'language', label: 'Language' },
+ { key: 'model', label: 'Model' },
+ {
+ key: 'segments',
+ label: 'Segments',
+ labelKey: 'text',
+ listItems: [
+ { key: 'text', label: 'Text' },
+ { key: 'start', label: 'Start (s)', format: 'number' },
+ { key: 'end', label: 'End (s)', format: 'number' },
+ { key: 'speaker_id', label: 'Speaker' },
+ ],
+ },
+ { key: 'prompt_audio_seconds', label: 'Audio Seconds', format: 'number' },
+ { key: 'total_tokens', label: 'Total Tokens', format: 'number' },
+ ],
+};
+
+export const generateSpeechOutputSchema: OutputSchema = {
+ fields: [...generatedFileFields, { key: 'format', label: 'Audio Format' }],
+};
+
+export const moderateTextOutputSchema: OutputSchema = { fields: moderationFields };
+
+export const moderateChatOutputSchema: OutputSchema = { fields: moderationFields };
+
+export const getModelOutputSchema: OutputSchema = { fields: modelFields };
+
+export const listModelsOutputSchema: OutputSchema = {
+ fields: [{ key: 'data', label: 'Models', labelKey: 'id', listItems: modelFields }],
+};
+
+export const createEmbeddingsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Request ID' },
+ { key: 'model', label: 'Model' },
+ {
+ key: 'data',
+ label: 'Embeddings',
+ labelKey: 'index',
+ listItems: [
+ { key: 'index', label: 'Index', format: 'number' },
+ { key: 'embedding', label: 'Vector' },
+ ],
+ },
+ {
+ key: 'usage',
+ label: 'Usage',
+ children: [
+ { key: 'prompt_tokens', label: 'Prompt Tokens', format: 'number' },
+ { key: 'total_tokens', label: 'Total Tokens', format: 'number' },
+ ],
+ },
+ ],
+};
+
+export const uploadFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'File ID' },
+ { key: 'filename', label: 'File Name' },
+ { key: 'purpose', label: 'Purpose' },
+ { key: 'bytes', label: 'Size', format: 'filesize' },
+ { key: 'mimetype', label: 'MIME Type' },
+ { key: 'source', label: 'Source' },
+ { key: 'created_at', label: 'Created At (Unix seconds)', format: 'number' },
+ ],
+};
+
+export const fileOutputSchema: OutputSchema = { fields: fileFields };
+
+export const listFilesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'files', label: 'Files', labelKey: 'filename', listItems: fileFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'total', label: 'Total', format: 'number' },
+ ],
+};
+
+export const deleteFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'File ID' },
+ { key: 'deleted', label: 'Deleted', format: 'boolean' },
+ ],
+};
+
+export const getFileSignedUrlOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'file_id', label: 'File ID' },
+ { key: 'url', label: 'Download URL', format: 'url' },
+ { key: 'expires_at', label: 'Expires At', format: 'datetime' },
+ ],
+};
+
+export const downloadFileOutputSchema: OutputSchema = {
+ fields: [
+ ...generatedFileFields,
+ { key: 'file_id', label: 'File ID' },
+ { key: 'mimetype', label: 'MIME Type' },
+ ],
+};
+
+export const agentOutputSchema: OutputSchema = { fields: agentFields };
+
+export const listAgentsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'agents', label: 'Agents', labelKey: 'name', listItems: agentFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'next_page_token', label: 'Next Page Token' },
+ ],
+};
+
+export const deleteAgentOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'agent_id', label: 'Agent ID' },
+ { key: 'deleted', label: 'Deleted', format: 'boolean' },
+ ],
+};
+
+export const conversationReplyOutputSchema: OutputSchema = { fields: conversationReplyFields };
+
+export const conversationOutputSchema: OutputSchema = { fields: conversationFields };
+
+export const listConversationsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'conversations', label: 'Conversations', labelKey: 'name', listItems: conversationFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const conversationHistoryOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'conversation_id', label: 'Conversation ID' },
+ { key: 'entries', label: 'Entries', labelKey: 'type', listItems: conversationEntryFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const conversationMessagesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'conversation_id', label: 'Conversation ID' },
+ { key: 'messages', label: 'Messages', labelKey: 'role', listItems: conversationEntryFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const deleteConversationOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'conversation_id', label: 'Conversation ID' },
+ { key: 'deleted', label: 'Deleted', format: 'boolean' },
+ ],
+};
+
+export const libraryOutputSchema: OutputSchema = { fields: libraryFields };
+
+export const listLibrariesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'libraries', label: 'Libraries', labelKey: 'name', listItems: libraryFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'next_page_token', label: 'Next Page Token' },
+ ],
+};
+
+export const deleteLibraryOutputSchema: OutputSchema = {
+ fields: [...libraryFields, { key: 'deleted', label: 'Deleted', format: 'boolean' }],
+};
+
+export const documentOutputSchema: OutputSchema = { fields: documentFields };
+
+export const listLibraryDocumentsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'documents', label: 'Documents', labelKey: 'name', listItems: documentFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'total', label: 'Total', format: 'number' },
+ { key: 'has_more', label: 'Has More', format: 'boolean' },
+ ],
+};
+
+export const documentStatusOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'document_id', label: 'Document ID' },
+ { key: 'process_status', label: 'Processing Status' },
+ { key: 'is_done', label: 'Done', format: 'boolean' },
+ { key: 'is_error', label: 'Error', format: 'boolean' },
+ ],
+};
+
+export const documentTextContentOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'document_id', label: 'Document ID' },
+ { key: 'text', label: 'Text' },
+ { key: 'length', label: 'Length', format: 'number' },
+ ],
+};
+
+export const deleteLibraryDocumentOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'library_id', label: 'Library ID' },
+ { key: 'document_id', label: 'Document ID' },
+ { key: 'deleted', label: 'Deleted', format: 'boolean' },
+ ],
+};
+
+export const reprocessDocumentOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'library_id', label: 'Library ID' },
+ { key: 'document_id', label: 'Document ID' },
+ { key: 'reprocessing', label: 'Reprocessing', format: 'boolean' },
+ ],
+};