import { AgentPieceTool, AppConnectionType, AppConnectionValue, ExecutionType, FlowRunId, PopulatedFlow, ProjectId, RespondResponse, ResumePayload, SeekPage, TriggerPayload, TriggerStrategy } from '@activepieces/shared'; import { LanguageModel, Tool } from 'ai'; import { BasicAuthProperty, CustomAuthProperty, InputPropertyMap, OAuth2Property, SecretTextProperty, StaticPropsValue } from '../property'; import { PieceAuthProperty } from '../property/authentication'; import { DelayPauseMetadata, PauseMetadata, WebhookPauseMetadata } from '@activepieces/shared'; export type BaseContext = { flows: FlowsContext; step: StepContext; auth: AppConnectionValueForAuthProperty; propsValue: StaticPropsValue; store: Store; project: { id: ProjectId; externalId: () => Promise; }; connections: ConnectionsManager; }; type ExtractCustomAuthProps = T extends CustomAuthProperty ? Props : never; type ExtractOAuth2Props = T extends OAuth2Property ? Props : never; export type AppConnectionValueForAuthProperty = T extends PieceAuthProperty[] ? AppConnectionValueForSingleAuthProperty : T extends PieceAuthProperty ? AppConnectionValueForSingleAuthProperty : T extends undefined ? undefined : never; type AppConnectionValueForSingleAuthProperty = T extends SecretTextProperty ? AppConnectionValue : T extends BasicAuthProperty ? AppConnectionValue : T extends CustomAuthProperty ? AppConnectionValue>> : T extends OAuth2Property ? AppConnectionValue>> : T extends undefined ? undefined : never; type AppWebhookTriggerHookContext = BaseContext & { webhookUrl: string; payload: TriggerPayload; app: { createListeners({ events, identifierValue, }: { events: string[]; identifierValue: string; }): void; }; }; type PollingTriggerHookContext = BaseContext & { setSchedule(schedule: { cronExpression: string; timezone?: string; }): void; }; type WebhookTriggerHookContext = BaseContext & { webhookUrl: string; payload: TriggerPayload; server: ServerContext; }; export type TriggerHookContext = S extends TriggerStrategy.APP_WEBHOOK ? AppWebhookTriggerHookContext : S extends TriggerStrategy.POLLING ? PollingTriggerHookContext : S extends TriggerStrategy.WEBHOOK ? WebhookTriggerHookContext & { server: ServerContext; } : never; export type TestOrRunHookContext = TriggerHookContext & { files: FilesService; }; export type StopHookParams = { response: RespondResponse; }; export type RespondHookParams = { response: RespondResponse; }; export type StopHook = (params?: StopHookParams) => void; export type RespondHook = (params?: RespondHookParams) => void; /** @deprecated Since 2026-04-12. Use {@link CreateWaitpointHook} and {@link WaitForWaitpointHook} instead. */ export type PauseHookParams = { pauseMetadata: PauseMetadata; }; /** @deprecated Since 2026-04-12. Use {@link CreateWaitpointHook} and {@link WaitForWaitpointHook} instead. */ export type PauseHook = (params: { pauseMetadata: Omit | Omit; }) => void; export type FlowsContext = { list(params?: ListFlowsContextParams): Promise>; current: { id: string; version: { id: string; }; }; }; export type StepContext = { name: string; }; export type ListFlowsContextParams = { externalIds?: string[]; }; export type PropertyContext = { server: ServerContext; project: { id: ProjectId; externalId: () => Promise; }; searchValue?: string; flows: FlowsContext; connections: ConnectionsManager; }; export type ServerContext = { apiUrl: string; publicUrl: string; token: string; }; export type CreateWaitpointParams = { type: 'DELAY' | 'WEBHOOK'; version?: 'V0' | 'V1'; resumeDateTime?: string; responseToSend?: RespondResponse; }; export type CreateWaitpointResult = { id: string; resumeUrl: string; buildResumeUrl: (params: { queryParams: Record; sync?: boolean; }) => string; }; export type CreateWaitpointHook = (params: CreateWaitpointParams) => Promise; export type WaitForWaitpointHook = (waitpointId: string) => void; export type RunContext = { id: FlowRunId; stop: StopHook; /** @deprecated Use createWaitpoint + waitForWaitpoint instead */ pause?: PauseHook; respond: RespondHook; createWaitpoint: CreateWaitpointHook; waitForWaitpoint: WaitForWaitpointHook; }; export type OnStartContext = Omit, 'flows'> & { run: Pick; payload: unknown; }; export type OutputContext = { update: (params: { data: { [key: string]: unknown; }; }) => Promise; }; type BaseActionContext = BaseContext & { executionType: ET; tags: TagsManager; server: ServerContext; files: FilesService; output: OutputContext; agent: AgentContext; run: RunContext; /** @deprecated Use waitpoint.buildResumeUrl() from createWaitpoint result instead */ generateResumeUrl?: (params: { queryParams: Record; sync?: boolean; }) => string; }; type BeginExecutionActionContext = BaseActionContext; type ResumeExecutionActionContext = BaseActionContext & { resumePayload: ResumePayload; }; export type ActionContext = BeginExecutionActionContext | ResumeExecutionActionContext; export type ConstructToolParams = { tools: AgentPieceTool[]; model: LanguageModel; }; export interface AgentContext { tools: (params: ConstructToolParams) => Promise>; } export interface FilesService { write({ fileName, data, }: { fileName: string; data: Buffer; }): Promise; } export interface ConnectionsManager { get(key: string): Promise | string | null>; } export interface TagsManager { add(params: { name: string; }): Promise; } export interface Store { put(key: string, value: T, scope?: StoreScope): Promise; get(key: string, scope?: StoreScope): Promise; delete(key: string, scope?: StoreScope): Promise; } export declare enum StoreScope { PROJECT = "COLLECTION", FLOW = "FLOW" } export {}; //# sourceMappingURL=index.d.ts.map