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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { AIProviderName, AiUsageEnvironment, AiUsageOrigin } from '@activepieces/core-utils'
import { z } from 'zod'
const ID_MAX = 21
const MODEL_ID_MAX = 255
const nullableId = z.string().max(ID_MAX).nullish().transform((value) => value ?? null)
const counter = z.number().finite().nonnegative()
const tokenCounter = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
export const AiUsageBlock = z.object({
v: z.literal(1),
origin: z.enum(AiUsageOrigin),
environment: z.enum(AiUsageEnvironment),
projectId: nullableId,
flowId: nullableId,
agentId: nullableId,
userId: nullableId,
runId: nullableId,
provider: z.enum(AIProviderName),
providerConfigId: nullableId,
modelId: z.string().min(1).max(MODEL_ID_MAX),
inputTokens: tokenCounter,
outputTokens: tokenCounter,
cacheReadTokens: tokenCounter,
cacheWriteTokens: tokenCounter,
reasoningTokens: tokenCounter,
reportedCostUsd: counter,
estimatedCostUsd: counter,
managedCredits: counter,
unpriced: z.boolean(),
})
export type AiUsageBlock = z.infer<typeof AiUsageBlock>