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

1.3 KB
Raw Blame
import { HttpMethod, getAccessTokenOrThrow } from '@activepieces/pieces-common';
import { createAction } from '@activepieces/pieces-framework';
import { clickupAuth } from '../../auth';
import { callClickUpApi, clickupCommon } from '../../common';
import { timeEntryOutputSchema } from '../../output-schemas';

export const clickupGetRunningTimeEntry = createAction({
  auth: clickupAuth,
  name: 'clickup_get_running_time_entry',
  classification: 'READ',
  displayName: 'Get Running Time Entry',
  description: 'Retrieve the time entry currently being tracked.',
  audience: 'ai',
  aiMetadata: {
    description:
      "Retrieve the time entry whose timer is currently running for the authenticated user in a workspace. Pick this to check whether a timer is active before calling Stop Time Entry; use Get Time Entry for a specific completed entry by ID. Read-only and idempotent; returns empty when no timer is running.",
    idempotent: true,
  },
  outputSchema: timeEntryOutputSchema,
  props: {
    workspace_id: clickupCommon.workspace_id(true),
  },
  async run(context) {
    const { workspace_id } = context.propsValue;
    const auth = getAccessTokenOrThrow(context.auth);

    const response = await callClickUpApi(
      HttpMethod.GET,
      `team/${workspace_id}/time_entries/current`,
      auth,
      undefined
    );

    return response.body;
  },
});