@powerhousedao/reactor-workflow 6.2.3-dev.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1140 @@
1
+ import { ActionBase, ActionRetryDefault, AppConnectionType, BasePropertySchema, DropdownOption, DropdownProperty, DropdownState, ExecutionType, InputPropertyMap, PackagePiece, PieceBase, RequireReactor, ServerContext, SetScheduleRequest, StoreScope, TestOrRunHookContext, TriggerBase, TriggerStrategy, WebhookHandshakeConfiguration } from "@powerhousedao/pieces-framework";
2
+ import { CORE_PIECE_NAME as CORE_PIECE_NAME$1 } from "@powerhousedao/pieces-framework/workflow";
3
+ import { BlockIdentity, BlockKind, BlockRef } from "@powerhousedao/pieces-framework/block-type";
4
+ import { Attributes, Context, Meter, Span, Tracer } from "@opentelemetry/api";
5
+ //#region src/pieces/activepieces/types.d.ts
6
+ type ApPropertyType = string;
7
+ type ApDropdownOption = Pick<DropdownOption<unknown>, "label" | "value"> & Partial<Pick<DropdownOption<unknown>, "description" | "icon">>;
8
+ type ApStaticDropdownState = Pick<DropdownState<unknown>, "disabled" | "placeholder"> & {
9
+ options: ApDropdownOption[];
10
+ };
11
+ type ApProperty = Partial<Pick<BasePropertySchema, "displayName" | "description" | "placeholder" | "advanced">> & Partial<Pick<DropdownProperty<unknown, boolean>, "refreshers">> & {
12
+ type?: ApPropertyType;
13
+ required?: boolean;
14
+ defaultValue?: unknown;
15
+ options?: ApStaticDropdownState | ((...args: unknown[]) => unknown);
16
+ props?: (...args: unknown[]) => unknown;
17
+ streaming?: boolean;
18
+ properties?: Record<string, ApProperty>;
19
+ width?: string;
20
+ icon?: string;
21
+ reveals?: string[];
22
+ variant?: string;
23
+ display?: string;
24
+ min?: number;
25
+ max?: number;
26
+ step?: number;
27
+ refreshOnSearch?: boolean;
28
+ formatProperty?: string;
29
+ showWhen?: unknown;
30
+ emptyChoice?: unknown;
31
+ };
32
+ interface ApPropertyGroup {
33
+ key?: string;
34
+ display?: string;
35
+ label?: string;
36
+ description?: string;
37
+ icon?: string;
38
+ props?: string[];
39
+ }
40
+ interface ApErrorHandlingOption {
41
+ defaultValue?: boolean;
42
+ hide?: boolean;
43
+ }
44
+ type ApAction = Partial<Pick<ActionBase, "name" | "displayName" | "description" | "requireAuth">> & {
45
+ props?: Record<string, ApProperty>;
46
+ outputSchema?: unknown;
47
+ audience?: string;
48
+ propertyGroups?: ApPropertyGroup[];
49
+ classification?: string;
50
+ errorHandlingOptions?: {
51
+ retryOnFailure?: ApErrorHandlingOption;
52
+ continueOnFailure?: ApErrorHandlingOption;
53
+ };
54
+ ports?: unknown;
55
+ requireReactor?: unknown;
56
+ defaultTimeoutSeconds?: unknown;
57
+ defaultRetry?: unknown;
58
+ run: (ctx: unknown) => Promise<unknown>;
59
+ test?: (ctx: unknown) => Promise<unknown>;
60
+ };
61
+ type ApTriggerStrategy = string;
62
+ type ApHandshakeConfiguration = Partial<Omit<WebhookHandshakeConfiguration, "strategy">> & {
63
+ strategy?: string;
64
+ };
65
+ type ApTrigger = Partial<Pick<TriggerBase, "name" | "displayName" | "description" | "requireAuth" | "sampleData">> & {
66
+ type?: ApTriggerStrategy;
67
+ testStrategy?: string;
68
+ display?: unknown;
69
+ requireReactor?: unknown;
70
+ props?: Record<string, ApProperty>;
71
+ propertyGroups?: ApPropertyGroup[];
72
+ outputSchema?: unknown;
73
+ handshakeConfiguration?: ApHandshakeConfiguration;
74
+ renewConfiguration?: {
75
+ strategy?: string;
76
+ cronExpression?: string;
77
+ };
78
+ onEnable?: (ctx: unknown) => Promise<void>;
79
+ onDisable?: (ctx: unknown) => Promise<void>;
80
+ onStart?: (ctx: unknown) => Promise<unknown>;
81
+ run?: (ctx: unknown) => Promise<unknown[]>;
82
+ test?: (ctx: unknown) => Promise<unknown[]>;
83
+ onHandshake?: (ctx: unknown) => Promise<unknown>;
84
+ onRenew?: (ctx: unknown) => Promise<void>;
85
+ };
86
+ type ApPiece = Pick<PieceBase, "displayName"> & Partial<Pick<PieceBase, "description" | "logoUrl" | "authors" | "minimumSupportedRelease" | "maximumSupportedRelease">> & {
87
+ categories?: string[];
88
+ deprecated?: boolean;
89
+ auth?: ApProperty | ApProperty[];
90
+ actions?: Record<string, ApAction> | (() => Record<string, ApAction>);
91
+ triggers?: Record<string, ApTrigger> | (() => Record<string, ApTrigger>);
92
+ getAction?: (name: string) => ApAction | undefined;
93
+ getTrigger?: (name: string) => ApTrigger | undefined;
94
+ metadata?: () => Record<string, unknown>;
95
+ };
96
+ //#endregion
97
+ //#region src/pieces/activepieces/loader.d.ts
98
+ interface LoadedPiece {
99
+ piece: ApPiece;
100
+ entryPath: string;
101
+ check: "constructor-name" | "structural";
102
+ }
103
+ declare function loadPieceFromDir(pieceDir: string): Promise<LoadedPiece>;
104
+ //#endregion
105
+ //#region src/pieces/activepieces/unsupported.d.ts
106
+ interface UnsupportedFeature {
107
+ feature: string;
108
+ issue: number;
109
+ reason: string;
110
+ }
111
+ interface TriggerRenew {
112
+ strategy: "CRON";
113
+ cronExpression: string;
114
+ }
115
+ //#endregion
116
+ //#region src/pieces/activepieces/descriptor.d.ts
117
+ interface PiecePropDescriptor {
118
+ name: string;
119
+ displayName: string;
120
+ description?: string;
121
+ placeholder?: string;
122
+ type: ApPropertyType;
123
+ required: boolean;
124
+ defaultValue?: unknown;
125
+ staticOptions?: ApDropdownOption[];
126
+ hasDynamicResolver: boolean;
127
+ dynamicResolverId?: string;
128
+ refreshers?: string[];
129
+ properties?: PiecePropDescriptor[];
130
+ advanced?: boolean;
131
+ width?: "half" | "full";
132
+ icon?: string;
133
+ reveals?: string[];
134
+ variant?: string;
135
+ display?: string;
136
+ min?: number;
137
+ max?: number;
138
+ step?: number;
139
+ refreshOnSearch?: boolean;
140
+ formatProperty?: string;
141
+ staticDisabled?: boolean;
142
+ staticPlaceholder?: string;
143
+ showWhen?: {
144
+ prop: string;
145
+ oneOf: unknown[];
146
+ };
147
+ emptyChoice?: string;
148
+ }
149
+ interface PiecePropertyGroupDescriptor {
150
+ key: string;
151
+ display: string;
152
+ label?: string;
153
+ description?: string;
154
+ icon?: string;
155
+ props: string[];
156
+ }
157
+ interface PieceErrorHandlingDescriptor {
158
+ retryOnFailure?: {
159
+ defaultValue?: boolean;
160
+ hide?: boolean;
161
+ };
162
+ continueOnFailure?: {
163
+ defaultValue?: boolean;
164
+ hide?: boolean;
165
+ };
166
+ }
167
+ interface PieceActionDescriptor {
168
+ name: string;
169
+ displayName: string;
170
+ description?: string;
171
+ requireAuth: boolean;
172
+ requireReactor?: RequireReactor;
173
+ defaultTimeoutSeconds?: number;
174
+ defaultRetry?: ActionRetryDefault;
175
+ props: PiecePropDescriptor[];
176
+ ports: readonly string[];
177
+ outputSchema?: unknown;
178
+ audience?: string;
179
+ propertyGroups?: PiecePropertyGroupDescriptor[];
180
+ classification?: string;
181
+ errorHandlingOptions?: PieceErrorHandlingDescriptor;
182
+ }
183
+ interface PieceTriggerDescriptor {
184
+ name: string;
185
+ displayName: string;
186
+ description?: string;
187
+ strategy: ApTriggerStrategy;
188
+ testStrategy?: string;
189
+ display?: string;
190
+ requireAuth: boolean;
191
+ requireReactor?: RequireReactor;
192
+ props: PiecePropDescriptor[];
193
+ ports: readonly string[];
194
+ propertyGroups?: PiecePropertyGroupDescriptor[];
195
+ outputSchema?: unknown;
196
+ hasSampleData: boolean;
197
+ sampleData?: unknown;
198
+ handshake?: {
199
+ strategy: string;
200
+ paramName?: string;
201
+ };
202
+ renew?: TriggerRenew;
203
+ onStart?: true;
204
+ unsupported?: UnsupportedFeature;
205
+ }
206
+ interface PieceAuthDescriptor {
207
+ type: ApPropertyType;
208
+ displayName?: string;
209
+ description?: string;
210
+ required?: boolean;
211
+ props?: PiecePropDescriptor[];
212
+ oauth2?: OAuth2MethodDescriptor;
213
+ unsupported?: UnsupportedFeature;
214
+ }
215
+ interface OAuth2MethodDescriptor {
216
+ authUrl: string;
217
+ tokenUrl: string;
218
+ scope: string[];
219
+ prompt?: "none" | "consent" | "login" | "omit";
220
+ pkce?: boolean;
221
+ pkceMethod?: "plain" | "S256";
222
+ authorizationMethod?: "HEADER" | "BODY";
223
+ grantType?: string;
224
+ extra?: Record<string, string>;
225
+ }
226
+ interface PieceSource {
227
+ packageName: string;
228
+ version: string;
229
+ }
230
+ interface PieceDescriptor {
231
+ id: string;
232
+ source: PieceSource;
233
+ displayName: string;
234
+ description?: string;
235
+ logoUrl?: string;
236
+ categories?: string[];
237
+ deprecated?: boolean;
238
+ auth?: PieceAuthDescriptor | PieceAuthDescriptor[];
239
+ minimumSupportedRelease?: string;
240
+ maximumSupportedRelease?: string;
241
+ actions: PieceActionDescriptor[];
242
+ triggers: PieceTriggerDescriptor[];
243
+ unsupported?: UnsupportedFeature;
244
+ }
245
+ interface BuildDescriptorOptions {
246
+ routed?: boolean;
247
+ hostFed?: boolean;
248
+ }
249
+ declare function buildDescriptor(piece: ApPiece, source: PieceSource, options?: BuildDescriptorOptions): PieceDescriptor;
250
+ //#endregion
251
+ //#region src/pieces/engine/resolution.d.ts
252
+ type PieceOrigin = "local" | "registry" | "activepieces" | "npm";
253
+ type BlockMatch = "exact" | "compatible" | "fallback" | "installed" | "missing";
254
+ interface BlockResolution {
255
+ requested: BlockRef;
256
+ resolved?: {
257
+ version: string;
258
+ source?: PieceOrigin;
259
+ };
260
+ match: BlockMatch;
261
+ note?: string;
262
+ latestVersion?: string;
263
+ unreachable?: string;
264
+ }
265
+ interface StepPieceRecord {
266
+ version: string;
267
+ source?: PieceOrigin;
268
+ match: BlockMatch;
269
+ note?: string;
270
+ }
271
+ //#endregion
272
+ //#region src/pieces/activepieces/context/store-scope.d.ts
273
+ type StoreScopeName = keyof typeof StoreScope;
274
+ //#endregion
275
+ //#region src/pieces/activepieces/context/files.d.ts
276
+ interface StagedFile {
277
+ token: string;
278
+ path: string;
279
+ fileName: string;
280
+ size: number;
281
+ contentType?: string;
282
+ }
283
+ //#endregion
284
+ //#region src/pieces/activepieces/context/action.d.ts
285
+ interface ActionContextIdentity {
286
+ runId?: string;
287
+ projectId?: string;
288
+ flowId?: string;
289
+ flowVersionId?: string;
290
+ stepName?: string;
291
+ }
292
+ //#endregion
293
+ //#region src/pieces/activepieces/context/trigger.d.ts
294
+ type RecordedSchedule = SetScheduleRequest;
295
+ type HookContextFor<S extends TriggerStrategy> = TestOrRunHookContext<undefined, InputPropertyMap, S>;
296
+ type RecordedListener = Parameters<HookContextFor<TriggerStrategy.APP_WEBHOOK>["app"]["createListeners"]>[0];
297
+ declare function extractDedupeKey(payload: unknown): string | undefined;
298
+ //#endregion
299
+ //#region src/pieces/activepieces/worker/protocol.d.ts
300
+ interface StagedInput {
301
+ ref: string;
302
+ path: string;
303
+ fileName?: string;
304
+ contentType?: string;
305
+ error?: string;
306
+ }
307
+ interface EgressPolicy {
308
+ allowHosts?: string[];
309
+ allowAddresses?: string[];
310
+ allowPrivateAddresses?: boolean;
311
+ allowPorts?: number[];
312
+ }
313
+ interface HostScopedRequest {
314
+ egress?: EgressPolicy;
315
+ maxFileBytes?: number;
316
+ deadline?: number;
317
+ hostCallTimeoutMs?: number;
318
+ }
319
+ interface ReactorRequestBinding {
320
+ requestId: string;
321
+ requireReactor: "read" | "write";
322
+ }
323
+ interface ReactorScopedRequest {
324
+ reactor?: ReactorRequestBinding;
325
+ }
326
+ interface PieceModuleRef {
327
+ bundleDir?: string;
328
+ entryPath?: string;
329
+ }
330
+ interface RunActionRequest extends HostScopedRequest, PieceModuleRef, ReactorScopedRequest {
331
+ actionName: string;
332
+ propsValue: Record<string, unknown>;
333
+ auth?: unknown;
334
+ stagingDir?: string;
335
+ uploadFiles?: boolean;
336
+ stagedInputs?: StagedInput[];
337
+ connections?: Record<string, unknown>;
338
+ storeScope?: string;
339
+ durableStore?: boolean;
340
+ captureLogs?: boolean;
341
+ liveOutput?: boolean;
342
+ executionType?: `${ExecutionType}`;
343
+ canPause?: boolean;
344
+ resumeBaseUrl?: string;
345
+ flows?: HostServerContext;
346
+ resumePayload?: unknown;
347
+ stepTest?: boolean;
348
+ identity?: ActionContextIdentity;
349
+ redactValues?: string[];
350
+ }
351
+ interface ResolveOptionsRequest extends HostScopedRequest, PieceModuleRef, ReactorScopedRequest {
352
+ actionName: string;
353
+ kind?: "action" | "trigger";
354
+ propName: string;
355
+ refresherValues?: Record<string, unknown>;
356
+ auth?: unknown;
357
+ searchValue?: string;
358
+ projectId?: string;
359
+ flows?: boolean;
360
+ }
361
+ interface TriggerHookRequest extends HostScopedRequest, PieceModuleRef, ReactorScopedRequest {
362
+ triggerName: string;
363
+ hook: "onEnable" | "onDisable" | "run" | "test" | "onHandshake" | "onRenew" | "onStart";
364
+ propsValue: Record<string, unknown>;
365
+ auth?: unknown;
366
+ storeState?: Record<string, unknown>;
367
+ durableStore?: boolean;
368
+ identity?: ActionContextIdentity;
369
+ isRepublish?: boolean;
370
+ payload?: unknown;
371
+ webhookUrl?: string;
372
+ server?: ServerContext;
373
+ flows?: HostServerContext;
374
+ redactValues?: string[];
375
+ }
376
+ interface CheckConnectionRequest extends HostScopedRequest, PieceModuleRef {
377
+ auth?: unknown;
378
+ }
379
+ interface DescribePieceRequest extends HostScopedRequest, PieceModuleRef {
380
+ packageName: string;
381
+ version: string;
382
+ }
383
+ interface WorkerPhaseTiming {
384
+ name: string;
385
+ start: number;
386
+ end: number;
387
+ parent?: string;
388
+ attributes?: Record<string, string | boolean>;
389
+ }
390
+ interface WorkerTimings {
391
+ received: number;
392
+ sent: number;
393
+ phases: WorkerPhaseTiming[];
394
+ ready?: number;
395
+ memory?: WorkerMemory;
396
+ }
397
+ interface WorkerMemory {
398
+ rss: number;
399
+ heapUsed: number;
400
+ heapTotal: number;
401
+ external: number;
402
+ }
403
+ type HostCallHandlers = Record<string, (payload: unknown) => Promise<unknown>>;
404
+ type HostNotifyHandlers = Record<string, (payload: unknown) => void>;
405
+ interface PieceLogEntry {
406
+ level: "log" | "info" | "warn" | "error" | "debug";
407
+ message: string;
408
+ at: number;
409
+ }
410
+ interface HostHttpRequest {
411
+ method: string;
412
+ path: string;
413
+ headers: Record<string, string>;
414
+ body?: string;
415
+ }
416
+ interface HostHttpResponse {
417
+ status: number;
418
+ headers?: Record<string, string>;
419
+ body?: string;
420
+ }
421
+ interface HostServerContext {
422
+ publicUrl?: string;
423
+ }
424
+ interface WaitpointCall {
425
+ type: "DELAY" | "WEBHOOK";
426
+ resumeDateTime?: string;
427
+ responseToSend?: RunResponse;
428
+ }
429
+ interface RunResponse {
430
+ status?: number;
431
+ body?: unknown;
432
+ headers?: Record<string, string>;
433
+ }
434
+ interface CreatedWaitpoint {
435
+ id: string;
436
+ resumeUrl: string;
437
+ }
438
+ type PausedStep = {
439
+ waitpointId: string;
440
+ } | {
441
+ pause: WaitpointCall;
442
+ token?: string;
443
+ };
444
+ //#endregion
445
+ //#region src/pieces/activepieces/resolver.d.ts
446
+ interface ResolvedPiece extends PieceModuleRef {
447
+ name: string;
448
+ version: string;
449
+ local: boolean;
450
+ }
451
+ interface PieceTarget {
452
+ name: string;
453
+ version: string;
454
+ source?: PieceOrigin;
455
+ }
456
+ interface PieceResolver {
457
+ resolve(target: PieceTarget): Promise<ResolvedPiece>;
458
+ }
459
+ interface LocalPiece {
460
+ name: string;
461
+ version: string;
462
+ entryPath?: string;
463
+ bundleDir?: string;
464
+ entryUrl?: string;
465
+ }
466
+ type LocalPieceLookup = (name: string) => LocalPiece | undefined | Promise<LocalPiece | undefined>;
467
+ declare function sourcedResolver(options: {
468
+ cacheDir: string;
469
+ lookup?: LocalPieceLookup;
470
+ timeoutMs?: number;
471
+ }): PieceResolver;
472
+ //#endregion
473
+ //#region src/pieces/activepieces/worker/transport.d.ts
474
+ interface TransportExit {
475
+ code: number | null;
476
+ signal: NodeJS.Signals | null;
477
+ }
478
+ type TransportEventMap = {
479
+ message: unknown;
480
+ exit: TransportExit;
481
+ };
482
+ type TransportEvent = keyof TransportEventMap;
483
+ type TransportListener<E extends TransportEvent> = (payload: TransportEventMap[E]) => void;
484
+ interface IPieceWorkerTransport {
485
+ send(message: unknown): void;
486
+ on<E extends TransportEvent>(event: E, listener: TransportListener<E>): void;
487
+ off<E extends TransportEvent>(event: E, listener: TransportListener<E>): void;
488
+ kill(): void;
489
+ readonly connected: boolean;
490
+ }
491
+ type PieceWorkerTransportFactory = () => IPieceWorkerTransport;
492
+ //#endregion
493
+ //#region src/pieces/activepieces/worker/reactor-rpc.d.ts
494
+ interface ReactorRpcTransport {
495
+ post(message: never): void;
496
+ onMessage(listener: (message: never) => void): () => void;
497
+ close(): void;
498
+ }
499
+ interface ReactorTap {
500
+ requireReactor: ReactorRequestBinding["requireReactor"];
501
+ open(transport: ReactorRpcTransport, request: {
502
+ requestId: string;
503
+ deadline: number;
504
+ }): () => void;
505
+ }
506
+ //#endregion
507
+ //#region src/pieces/engine/types.d.ts
508
+ interface PropertySettingDef {
509
+ prop: string;
510
+ mode?: string;
511
+ schema?: unknown;
512
+ }
513
+ interface WorkflowTriggerDef {
514
+ id: string;
515
+ pieceName: string;
516
+ pieceVersion: string;
517
+ triggerName: string;
518
+ connectionId?: string | null;
519
+ reactorConnectionId?: string | null;
520
+ config?: unknown;
521
+ propertySettings?: PropertySettingDef[] | null;
522
+ }
523
+ interface WorkflowStepDef {
524
+ id: string;
525
+ key: string;
526
+ name?: string;
527
+ pieceName: string;
528
+ pieceVersion: string;
529
+ actionName: string;
530
+ connectionId?: string | null;
531
+ reactorConnectionId?: string | null;
532
+ config: unknown;
533
+ timeoutSeconds?: number | null;
534
+ propertySettings?: PropertySettingDef[] | null;
535
+ skip?: boolean | null;
536
+ retry?: unknown;
537
+ }
538
+ interface WorkflowEdgeDef {
539
+ id: string;
540
+ from: string;
541
+ to: string;
542
+ port: string;
543
+ condition?: string | null;
544
+ }
545
+ interface WorkflowVariableDef {
546
+ key: string;
547
+ value?: unknown;
548
+ }
549
+ interface WorkflowDefinition {
550
+ name?: string;
551
+ trigger?: WorkflowTriggerDef | null;
552
+ steps: WorkflowStepDef[];
553
+ edges: WorkflowEdgeDef[];
554
+ variables?: WorkflowVariableDef[];
555
+ }
556
+ interface BlockExecution {
557
+ block: BlockRef;
558
+ config: unknown;
559
+ connectionId?: string | null;
560
+ reactorConnectionId?: string | null;
561
+ step: WorkflowStepDef;
562
+ redactValues?: string[];
563
+ defaultTimeoutSeconds?: number;
564
+ resume?: {
565
+ payload: unknown;
566
+ };
567
+ }
568
+ interface BlockDefaults {
569
+ timeoutSeconds?: number;
570
+ retry?: unknown;
571
+ }
572
+ interface WaitpointApproval {
573
+ title: string;
574
+ body: string | null;
575
+ approveLabel: string;
576
+ rejectLabel: string;
577
+ reasonRequiredOn: "none" | "reject" | "both";
578
+ approvers: string[];
579
+ }
580
+ interface WaitpointRequest extends WaitpointCall {
581
+ stepId: string;
582
+ stepKey: string;
583
+ pieceName: string;
584
+ blockName: string;
585
+ approval?: WaitpointApproval;
586
+ expiresAt?: string;
587
+ token?: string;
588
+ }
589
+ interface WaitpointPort {
590
+ create(request: WaitpointRequest): Promise<CreatedWaitpoint>;
591
+ resumeBaseUrl?: string;
592
+ }
593
+ interface FlowsPort {
594
+ list(params: {
595
+ externalIds?: string[];
596
+ }): Promise<{
597
+ data: unknown[];
598
+ }>;
599
+ request(request: HostHttpRequest): Promise<HostHttpResponse>;
600
+ publicUrl?: string;
601
+ }
602
+ interface BlockResult {
603
+ output: unknown;
604
+ port?: string;
605
+ redactValues?: string[];
606
+ resolution?: BlockResolution;
607
+ paused?: {
608
+ waitpointId: string;
609
+ };
610
+ response?: RunResponse;
611
+ stopped?: boolean;
612
+ }
613
+ interface BlockExecutor {
614
+ execute(execution: BlockExecution): Promise<BlockResult>;
615
+ }
616
+ type StepExecutionStatus = "WAITING" | "SUCCEEDED" | "FAILED" | "SKIPPED" | "REPLAYED" | "INDETERMINATE";
617
+ interface StepExecutionRecord {
618
+ stepId: string;
619
+ path?: string;
620
+ key: string;
621
+ pieceName: string;
622
+ blockName: string;
623
+ status: StepExecutionStatus;
624
+ input?: unknown;
625
+ output?: unknown;
626
+ /**
627
+ * Journaled in the output column in place of `output`, when there is no
628
+ * output to hand a caller but the row still has to say something.
629
+ *
630
+ * One use today: a REPLAYED step whose journaled output the payload cap
631
+ * truncated. The record's `output` stays absent — a caller must not be
632
+ * handed a marker where real data goes — while the row keeps the marker, so
633
+ * a SECOND rerun still knows the output is gone and tells a downstream step
634
+ * by name instead of resolving it to nothing.
635
+ */
636
+ journaledOutput?: unknown;
637
+ port?: string;
638
+ error?: string;
639
+ errorName?: string;
640
+ startedAt?: string;
641
+ endedAt?: string;
642
+ piece?: StepPieceRecord;
643
+ configHash?: string;
644
+ attempts?: number;
645
+ carried?: boolean;
646
+ }
647
+ type WorkflowRunStatus = "SUCCEEDED" | "FAILED" | "CANCELLED" | "WAITING";
648
+ interface WorkflowRunResult {
649
+ status: WorkflowRunStatus;
650
+ steps: StepExecutionRecord[];
651
+ error?: string;
652
+ errorName?: string;
653
+ warnings?: string[];
654
+ waiting?: {
655
+ stepId: string;
656
+ waitpointId: string;
657
+ };
658
+ }
659
+ //#endregion
660
+ //#region src/telemetry.d.ts
661
+ declare const TELEMETRY_SCOPE = "@powerhousedao/reactor-workflow";
662
+ interface WorkflowTelemetryOptions {
663
+ tracer?: Tracer;
664
+ meter?: Meter;
665
+ }
666
+ interface WorkerPoolStats {
667
+ size: number;
668
+ active: number;
669
+ idle: number;
670
+ waiting: number;
671
+ }
672
+ declare class WorkflowTelemetry {
673
+ readonly tracer: Tracer;
674
+ private readonly meter;
675
+ private readonly runs;
676
+ private readonly runDuration;
677
+ private readonly stepDuration;
678
+ private readonly phaseDuration;
679
+ private dispatcherGauges?;
680
+ private suspendedGauge?;
681
+ private poolGauges?;
682
+ constructor(options?: WorkflowTelemetryOptions);
683
+ phase<T>(name: string, attributes: Attributes, fn: (span: Span) => Promise<T>, parent?: Context): Promise<T>;
684
+ workerTimings(request: Span, timings: WorkerTimings, forkedAt: number, ipc: {
685
+ sent: number;
686
+ received: number;
687
+ }): void;
688
+ recordPhase(name: string, ms: number): void;
689
+ span<T>(name: string, attributes: Attributes, fn: (span: Span) => Promise<T>, parent?: Context): Promise<T>;
690
+ recordRun(ms: number, status: string, triggerKind: string): void;
691
+ recordStep(ms: number, pieceName: string, status: string): void;
692
+ observeWorkerPool(stats: () => WorkerPoolStats): () => void;
693
+ observeDispatcher(stats: () => {
694
+ inFlight: number;
695
+ waiting: number;
696
+ utilization: number;
697
+ }): () => void;
698
+ observeSuspended(count: () => number): () => void;
699
+ private createPoolGauges;
700
+ }
701
+ //#endregion
702
+ //#region src/pieces/activepieces/worker/host.d.ts
703
+ interface PieceWorkerResult {
704
+ output: unknown;
705
+ touched: string[];
706
+ tlsPoisoned: boolean;
707
+ paused?: PausedStep;
708
+ response?: RunResponse;
709
+ stopped?: boolean;
710
+ files?: StagedFile[];
711
+ storeState?: Record<string, unknown>;
712
+ schedules?: RecordedSchedule[];
713
+ listeners?: RecordedListener[];
714
+ }
715
+ interface RequestTaps {
716
+ hostCalls?: HostCallHandlers;
717
+ notifications?: HostNotifyHandlers;
718
+ reactor?: ReactorTap;
719
+ }
720
+ interface RequestOptions extends RequestTaps {
721
+ timeoutMs?: number;
722
+ hostCallTimeoutMs?: number;
723
+ }
724
+ interface ModelManifestSource {
725
+ entries(): unknown[];
726
+ lookup?(documentType?: string): unknown[] | Promise<unknown[]>;
727
+ }
728
+ interface PieceWorkerOptions {
729
+ entryPath?: string;
730
+ telemetry?: WorkflowTelemetry;
731
+ defaultTimeoutMs?: number;
732
+ transport?: PieceWorkerTransportFactory;
733
+ hostCallTimeoutMs?: number;
734
+ models?: ModelManifestSource;
735
+ heapMb?: number;
736
+ }
737
+ interface PieceWorkerHealth {
738
+ alive: boolean;
739
+ memory?: WorkerMemory;
740
+ tlsPoisoned: boolean;
741
+ }
742
+ interface IPieceWorker {
743
+ runAction(request: RunActionRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
744
+ resolveOptions(request: ResolveOptionsRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
745
+ checkConnection(request: CheckConnectionRequest, options?: {
746
+ timeoutMs?: number;
747
+ }): Promise<PieceWorkerResult>;
748
+ describePiece(request: DescribePieceRequest, options?: {
749
+ timeoutMs?: number;
750
+ }): Promise<PieceWorkerResult>;
751
+ runTriggerHook(request: TriggerHookRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
752
+ dispose(): void;
753
+ health?(): PieceWorkerHealth;
754
+ }
755
+ declare class PieceWorker implements IPieceWorker {
756
+ private readonly connect;
757
+ private readonly defaultTimeoutMs;
758
+ private readonly hostCallTimeoutMs;
759
+ private readonly models;
760
+ private readonly telemetry;
761
+ private worker;
762
+ private forkedAt;
763
+ private queue;
764
+ private nextId;
765
+ private disposed;
766
+ private memory;
767
+ private tlsPoisoned;
768
+ constructor(options?: PieceWorkerOptions);
769
+ runAction(request: RunActionRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
770
+ resolveOptions(request: ResolveOptionsRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
771
+ checkConnection(request: CheckConnectionRequest, options?: {
772
+ timeoutMs?: number;
773
+ }): Promise<PieceWorkerResult>;
774
+ describePiece(request: DescribePieceRequest, options?: {
775
+ timeoutMs?: number;
776
+ }): Promise<PieceWorkerResult>;
777
+ runTriggerHook(request: TriggerHookRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
778
+ private enqueue;
779
+ dispose(): void;
780
+ health(): PieceWorkerHealth;
781
+ private forgetChild;
782
+ private noteReply;
783
+ private spawn;
784
+ private sendModels;
785
+ private modelEntries;
786
+ private openReactor;
787
+ private execute;
788
+ private serveHostCall;
789
+ }
790
+ //#endregion
791
+ //#region src/pieces/activepieces/worker/pool.d.ts
792
+ type PieceWorkerLane = "run" | "trigger" | "design";
793
+ interface PieceWorkerPoolOptions extends PieceWorkerOptions {
794
+ size?: number;
795
+ maxQueueDepth?: number;
796
+ triggerSlots?: number;
797
+ designSlots?: number;
798
+ minWarm?: number;
799
+ maxRequests?: number;
800
+ idleMs?: number;
801
+ maxConcurrentForks?: number;
802
+ reactorThreads?: number;
803
+ memory?: () => ContainerMemory | undefined;
804
+ createWorker?: (options: PieceWorkerOptions) => IPieceWorker;
805
+ }
806
+ interface ContainerMemory {
807
+ limit: number;
808
+ used: number;
809
+ }
810
+ interface PieceWorkerPoolStats {
811
+ size: number;
812
+ active: number;
813
+ idle: number;
814
+ waiting: number;
815
+ }
816
+ declare class PieceWorkerSession implements IPieceWorker {
817
+ private readonly pool;
818
+ /** @internal */
819
+ readonly lane: PieceWorkerLane;
820
+ private closed;
821
+ constructor(pool: PieceWorkerPool,
822
+ /** @internal */
823
+ lane: PieceWorkerLane);
824
+ runAction(request: RunActionRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
825
+ resolveOptions(request: ResolveOptionsRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
826
+ checkConnection(request: CheckConnectionRequest, options?: {
827
+ timeoutMs?: number;
828
+ }): Promise<PieceWorkerResult>;
829
+ describePiece(request: DescribePieceRequest, options?: {
830
+ timeoutMs?: number;
831
+ }): Promise<PieceWorkerResult>;
832
+ runTriggerHook(request: TriggerHookRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
833
+ close(): void;
834
+ /** @internal */
835
+ isClosed(): boolean;
836
+ dispose(): void;
837
+ }
838
+ declare class PieceWorkerPool {
839
+ readonly size: number;
840
+ /** @internal */
841
+ readonly telemetry: WorkflowTelemetry | undefined;
842
+ private readonly maxQueueDepth;
843
+ readonly triggerSlots: number;
844
+ private readonly designSlots;
845
+ private readonly minWarm;
846
+ private readonly maxRequests;
847
+ private readonly idleMs;
848
+ private readonly maxConcurrentForks;
849
+ private readonly heapMb;
850
+ private readonly memory;
851
+ private readonly createWorker;
852
+ private readonly workerOptions;
853
+ private readonly children;
854
+ private readonly waiters;
855
+ private largestChild;
856
+ private idleTimer;
857
+ private bootTimer;
858
+ private disposed;
859
+ constructor(options?: PieceWorkerPoolOptions);
860
+ session(lane?: PieceWorkerLane): PieceWorkerSession;
861
+ stats(): PieceWorkerPoolStats;
862
+ memoryStats(): Record<string, number>;
863
+ dispose(): void;
864
+ /** @internal — one request on a leased child. */
865
+ request<T>(session: PieceWorkerSession, key: string | undefined, fn: (worker: IPieceWorker) => Promise<T>): Promise<T>;
866
+ /** @internal — a session that closed. */
867
+ closeSession(session: PieceWorkerSession): void;
868
+ private lease;
869
+ private take;
870
+ private fork;
871
+ private roomForChild;
872
+ private giveBack;
873
+ private spent;
874
+ private retire;
875
+ private dispatch;
876
+ private redispatchAt;
877
+ private scheduleIdleSweep;
878
+ private sweepIdle;
879
+ private retirable;
880
+ }
881
+ //#endregion
882
+ //#region src/pieces/engine/secrets.d.ts
883
+ interface SecretOwner {
884
+ documentId: string;
885
+ kind: "connection" | "workflow";
886
+ }
887
+ interface SecretProvider {
888
+ get(ref: string, owner: SecretOwner): Promise<string>;
889
+ }
890
+ interface SecretStat {
891
+ ref: string;
892
+ label: string | null;
893
+ ownerId: string | null;
894
+ createdBy: string | null;
895
+ version: number;
896
+ status: "ACTIVE" | "DELETED";
897
+ createdAt: string;
898
+ updatedAt: string;
899
+ }
900
+ interface SecretStore extends SecretProvider {
901
+ get(ref: string, owner: SecretOwner | null): Promise<string>;
902
+ create(input: {
903
+ value: string;
904
+ label?: string;
905
+ ownerId: string | null;
906
+ createdBy?: string | null;
907
+ }): Promise<SecretStat>;
908
+ rotate(ref: string, value: string): Promise<SecretStat>;
909
+ stat(ref: string): Promise<SecretStat>;
910
+ list(): Promise<SecretStat[]>;
911
+ delete(ref: string): Promise<void>;
912
+ }
913
+ declare class InMemorySecretProvider implements SecretProvider {
914
+ private readonly secrets;
915
+ constructor(secrets: Record<string, string>);
916
+ get(ref: string): Promise<string>;
917
+ }
918
+ //#endregion
919
+ //#region src/pieces/engine/expressions.d.ts
920
+ interface ExpressionScope {
921
+ trigger?: unknown;
922
+ steps: Record<string, {
923
+ output?: unknown;
924
+ error?: string;
925
+ }>;
926
+ variables: Record<string, unknown>;
927
+ }
928
+ //#endregion
929
+ //#region src/pieces/engine/connections.d.ts
930
+ type ConnectionAuthType = `${AppConnectionType.SECRET_TEXT}` | `${AppConnectionType.BASIC_AUTH}` | `${AppConnectionType.CUSTOM_AUTH}` | `${AppConnectionType.OAUTH2}` | `${AppConnectionType.OIDC}` | "NONE";
931
+ interface ConnectionSource {
932
+ authType: ConnectionAuthType;
933
+ config?: Record<string, unknown>;
934
+ secretRefs?: {
935
+ name: string;
936
+ ref: string;
937
+ }[];
938
+ }
939
+ interface ConnectionRequest {
940
+ piecePackage?: string;
941
+ stepId?: string;
942
+ stepKey?: string;
943
+ }
944
+ interface ResolvedConnection {
945
+ auth: unknown;
946
+ secretValues: string[];
947
+ }
948
+ interface EngineConnectionResolver {
949
+ resolve(connectionId: string, request?: ConnectionRequest): Promise<unknown>;
950
+ resolveWithSecrets?(connectionId: string, request?: ConnectionRequest): Promise<ResolvedConnection>;
951
+ }
952
+ declare class StaticConnectionResolver implements EngineConnectionResolver {
953
+ private readonly secrets;
954
+ private readonly connections;
955
+ constructor(connections: Record<string, ConnectionSource>, secrets: SecretProvider);
956
+ resolve(connectionId: string): Promise<unknown>;
957
+ resolveWithSecrets(connectionId: string): Promise<ResolvedConnection>;
958
+ }
959
+ //#endregion
960
+ //#region src/pieces/engine/attachment-cache.d.ts
961
+ interface CachedAttachmentMeta {
962
+ fileName?: string;
963
+ contentType?: string;
964
+ size: number;
965
+ }
966
+ interface AttachmentCacheOptions {
967
+ dir: string;
968
+ maxBytes: number;
969
+ }
970
+ declare class AttachmentCache {
971
+ private readonly options;
972
+ constructor(options: AttachmentCacheOptions);
973
+ private entry;
974
+ static cacheable(ref: string): boolean;
975
+ get(ref: string, destPath: string): Promise<CachedAttachmentMeta | undefined>;
976
+ put(ref: string, srcPath: string, meta: Omit<CachedAttachmentMeta, "size">): Promise<void>;
977
+ private remove;
978
+ private evict;
979
+ }
980
+ //#endregion
981
+ //#region src/pieces/engine/blocks.d.ts
982
+ interface AttachmentPort {
983
+ read(ref: string, destPath: string, signal?: AbortSignal): Promise<{
984
+ fileName?: string;
985
+ contentType?: string;
986
+ }>;
987
+ authorize?(ref: string): Promise<void>;
988
+ write(file: {
989
+ path: string;
990
+ fileName: string;
991
+ size: number;
992
+ contentType?: string;
993
+ }, signal?: AbortSignal): Promise<string>;
994
+ }
995
+ interface PieceStorePort {
996
+ get(key: string, scope: StoreScopeName): Promise<unknown>;
997
+ put(key: string, value: unknown, scope: StoreScopeName): Promise<void>;
998
+ delete(key: string, scope: StoreScopeName): Promise<void>;
999
+ }
1000
+ interface ActivepiecesBlockExecutorOptions {
1001
+ cacheDir: string;
1002
+ resolveBlock?: (block: BlockRef) => Promise<BlockResolution>;
1003
+ connections?: EngineConnectionResolver;
1004
+ worker?: IPieceWorker | (() => IPieceWorker | undefined);
1005
+ defaultTimeoutMs?: number;
1006
+ stagingRoot?: string;
1007
+ attachments?: AttachmentPort;
1008
+ attachmentCache?: AttachmentCache;
1009
+ pieceStore?: PieceStorePort;
1010
+ resolver?: PieceResolver;
1011
+ reactorAccess?: (request: StepReactorRequest) => Promise<ReactorTap | undefined>;
1012
+ egress?: EgressPolicy | null;
1013
+ onPieceLog?: (entry: PieceLogEntry, execution: BlockExecution) => void;
1014
+ onPartialOutput?: (output: unknown, execution: BlockExecution) => void;
1015
+ identity?: () => Omit<ActionContextIdentity, "stepName"> | undefined;
1016
+ stepTest?: () => boolean;
1017
+ waitpoints?: () => WaitpointPort | undefined;
1018
+ flows?: () => FlowsPort | undefined;
1019
+ telemetry?: WorkflowTelemetry;
1020
+ }
1021
+ interface StepReactorRequest {
1022
+ block: ParsedBlockType;
1023
+ reactorConnectionId?: string | null;
1024
+ }
1025
+ interface ParsedBlockType {
1026
+ packageName: string;
1027
+ version: string;
1028
+ source?: PieceOrigin;
1029
+ kind: BlockKind;
1030
+ name: string;
1031
+ }
1032
+ declare class ActivepiecesBlockExecutor implements BlockExecutor {
1033
+ private readonly options;
1034
+ private own;
1035
+ private readonly resolver;
1036
+ constructor(options: ActivepiecesBlockExecutorOptions);
1037
+ private worker;
1038
+ execute(execution: BlockExecution): Promise<BlockResult>;
1039
+ private builtinOptions;
1040
+ private run;
1041
+ private resolveConnection;
1042
+ private stageInputs;
1043
+ private readAttachment;
1044
+ private uploadHandlers;
1045
+ private checkStagedFile;
1046
+ private ingestFiles;
1047
+ dispose(): void;
1048
+ }
1049
+ declare class CompositeBlockExecutor implements BlockExecutor {
1050
+ private readonly pieces;
1051
+ private readonly handlers;
1052
+ constructor(pieces: BlockExecutor, handlers?: Record<string, BlockExecutor>);
1053
+ execute(execution: BlockExecution): Promise<BlockResult>;
1054
+ }
1055
+ //#endregion
1056
+ //#region src/pieces/engine/retry.d.ts
1057
+ type BackoffKind = "FIXED" | "EXPONENTIAL";
1058
+ /** A retry policy with every field resolved; `maxAttempts` is already clamped. */
1059
+ interface EffectiveRetryPolicy {
1060
+ maxAttempts: number;
1061
+ backoff: BackoffKind;
1062
+ initialDelaySeconds: number;
1063
+ maxDelaySeconds: number;
1064
+ /** Empty means every error is retryable; see {@link isRetryableError}. */
1065
+ retryOn: readonly string[];
1066
+ }
1067
+ //#endregion
1068
+ //#region src/pieces/engine/coordinator.d.ts
1069
+ /** One step a prior run already completed, as a rerun replays it. */
1070
+ interface ReplayedStep {
1071
+ output?: unknown;
1072
+ port?: string | null;
1073
+ /**
1074
+ * The step SUCCEEDED, but the run journal truncated its output past the
1075
+ * payload cap, so there is nothing to replay.
1076
+ *
1077
+ * It still replays, rather than running again: the step had side effects and
1078
+ * re-running it would charge the card twice (backlog item 15). Its scope
1079
+ * entry carries an unavailable value instead of data, so a downstream step
1080
+ * that reads `steps.<key>.output…` fails the rerun by name.
1081
+ */
1082
+ outputTruncated?: boolean;
1083
+ /**
1084
+ * What the journal holds in place of that output — the truncation marker
1085
+ * itself — to be journaled again on this run's REPLAYED row.
1086
+ *
1087
+ * Opaque to the engine: it is never resolved, only written back. Without it
1088
+ * the REPLAYED row's output is NULL, and the NEXT rerun reads a NULL as an
1089
+ * ordinary replay with no output: the truncation fact is gone after one
1090
+ * generation, and a downstream step is handed nothing instead of being told
1091
+ * by name why there is nothing.
1092
+ */
1093
+ truncatedOutput?: unknown;
1094
+ }
1095
+ /** A step an earlier leg of a suspended run journaled, as its resume carries it. */
1096
+ interface CarriedStep {
1097
+ status: "SUCCEEDED" | "REPLAYED" | "FAILED" | "SKIPPED";
1098
+ port: string | null;
1099
+ output: () => unknown;
1100
+ error?: string;
1101
+ }
1102
+ interface RunWorkflowOptions {
1103
+ definition: WorkflowDefinition;
1104
+ executor: BlockExecutor;
1105
+ triggerPayload?: unknown;
1106
+ completedSteps?: Map<string, ReplayedStep>;
1107
+ loopItems?: Map<string, unknown[]>;
1108
+ defaultRetry?: EffectiveRetryPolicy | null;
1109
+ deadline?: number;
1110
+ sleep?: (ms: number) => Promise<void>;
1111
+ onStep?: (record: StepExecutionRecord, ordinal: number) => void | Promise<void>;
1112
+ redactValues?: string[];
1113
+ priorSteps?: ExpressionScope["steps"];
1114
+ declaredPorts?: (block: BlockRef) => readonly string[] | undefined;
1115
+ blockDefaults?: (block: BlockRef) => Promise<BlockDefaults | undefined>;
1116
+ carriedSteps?: Map<string, CarriedStep>;
1117
+ resume?: {
1118
+ stepId: string;
1119
+ payload: unknown;
1120
+ };
1121
+ firstOrdinal?: number;
1122
+ onRespond?: (response: RunResponse) => void;
1123
+ }
1124
+ declare function runWorkflow(options: RunWorkflowOptions): Promise<WorkflowRunResult>;
1125
+ //#endregion
1126
+ //#region src/reactor/piece-registry.d.ts
1127
+ declare class PieceRegistry {
1128
+ private byName;
1129
+ setPieces(pieces: readonly LocalPiece[]): void;
1130
+ lookup: (name: string) => LocalPiece | undefined;
1131
+ entries(): LocalPiece[];
1132
+ versions(): Record<string, string>;
1133
+ /** Test seam: a suite that filled the registry starts the next from nothing. */
1134
+ reset(): void;
1135
+ }
1136
+ declare const packagePieces: PieceRegistry;
1137
+ //#endregion
1138
+ export { PieceResolver as A, buildDescriptor as B, FlowsPort as C, ReactorTap as D, WorkflowRunResult as E, extractDedupeKey as F, BlockMatch as I, BlockResolution as L, sourcedResolver as M, EgressPolicy as N, LocalPiece as O, RecordedSchedule as P, PieceOrigin as R, BlockExecution as S, StepExecutionRecord as T, loadPieceFromDir as V, PieceWorker as _, runWorkflow as a, WorkflowTelemetry as b, CompositeBlockExecutor as c, InMemorySecretProvider as d, SecretStat as f, ModelManifestSource as g, IPieceWorker as h, ReplayedStep as i, PieceTarget as j, PackagePiece as k, ConnectionRequest as l, PieceWorkerPool as m, packagePieces as n, ActivepiecesBlockExecutor as o, SecretStore as p, CORE_PIECE_NAME$1 as r, AttachmentPort as s, PieceRegistry as t, StaticConnectionResolver as u, PieceWorkerResult as v, PropertySettingDef as w, WorkflowTelemetryOptions as x, TELEMETRY_SCOPE as y, PieceDescriptor as z };
1139
+ export {};
1140
+ //# sourceMappingURL=piece-registry-dvS95c3E.d.ts.map