@powerhousedao/reactor-workflow 6.2.3 → 6.3.0-dev.1

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.
@@ -1,6 +1,7 @@
1
- import { ActionBase, AppConnectionType, BasePropertySchema, DropdownOption, DropdownProperty, DropdownState, ExecutionType, InputPropertyMap, PackagePiece, PieceBase, ReactorService, ServerContext, SetScheduleRequest, StoreScope, TestOrRunHookContext, TriggerBase, TriggerStrategy, WebhookHandshakeConfiguration } from "@powerhousedao/pieces-framework";
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
2
  import { CORE_PIECE_NAME as CORE_PIECE_NAME$1 } from "@powerhousedao/pieces-framework/workflow";
3
- import { BlockIdentity, BlockRef } from "@powerhousedao/pieces-framework/block-type";
3
+ import { BlockIdentity, BlockKind, BlockRef } from "@powerhousedao/pieces-framework/block-type";
4
+ import { Attributes, Context, Meter, Span, Tracer } from "@opentelemetry/api";
4
5
  //#region src/pieces/activepieces/types.d.ts
5
6
  type ApPropertyType = string;
6
7
  type ApDropdownOption = Pick<DropdownOption<unknown>, "label" | "value"> & Partial<Pick<DropdownOption<unknown>, "description" | "icon">>;
@@ -13,6 +14,7 @@ type ApProperty = Partial<Pick<BasePropertySchema, "displayName" | "description"
13
14
  defaultValue?: unknown;
14
15
  options?: ApStaticDropdownState | ((...args: unknown[]) => unknown);
15
16
  props?: (...args: unknown[]) => unknown;
17
+ streaming?: boolean;
16
18
  properties?: Record<string, ApProperty>;
17
19
  width?: string;
18
20
  icon?: string;
@@ -50,6 +52,9 @@ type ApAction = Partial<Pick<ActionBase, "name" | "displayName" | "description"
50
52
  continueOnFailure?: ApErrorHandlingOption;
51
53
  };
52
54
  ports?: unknown;
55
+ requireReactor?: unknown;
56
+ defaultTimeoutSeconds?: unknown;
57
+ defaultRetry?: unknown;
53
58
  run: (ctx: unknown) => Promise<unknown>;
54
59
  test?: (ctx: unknown) => Promise<unknown>;
55
60
  };
@@ -61,6 +66,7 @@ type ApTrigger = Partial<Pick<TriggerBase, "name" | "displayName" | "description
61
66
  type?: ApTriggerStrategy;
62
67
  testStrategy?: string;
63
68
  display?: unknown;
69
+ requireReactor?: unknown;
64
70
  props?: Record<string, ApProperty>;
65
71
  propertyGroups?: ApPropertyGroup[];
66
72
  outputSchema?: unknown;
@@ -163,6 +169,9 @@ interface PieceActionDescriptor {
163
169
  displayName: string;
164
170
  description?: string;
165
171
  requireAuth: boolean;
172
+ requireReactor?: RequireReactor;
173
+ defaultTimeoutSeconds?: number;
174
+ defaultRetry?: ActionRetryDefault;
166
175
  props: PiecePropDescriptor[];
167
176
  ports: readonly string[];
168
177
  outputSchema?: unknown;
@@ -179,6 +188,7 @@ interface PieceTriggerDescriptor {
179
188
  testStrategy?: string;
180
189
  display?: string;
181
190
  requireAuth: boolean;
191
+ requireReactor?: RequireReactor;
182
192
  props: PiecePropDescriptor[];
183
193
  ports: readonly string[];
184
194
  propertyGroups?: PiecePropertyGroupDescriptor[];
@@ -190,6 +200,7 @@ interface PieceTriggerDescriptor {
190
200
  paramName?: string;
191
201
  };
192
202
  renew?: TriggerRenew;
203
+ onStart?: true;
193
204
  unsupported?: UnsupportedFeature;
194
205
  }
195
206
  interface PieceAuthDescriptor {
@@ -291,6 +302,7 @@ interface StagedInput {
291
302
  path: string;
292
303
  fileName?: string;
293
304
  contentType?: string;
305
+ error?: string;
294
306
  }
295
307
  interface EgressPolicy {
296
308
  allowHosts?: string[];
@@ -301,16 +313,26 @@ interface EgressPolicy {
301
313
  interface HostScopedRequest {
302
314
  egress?: EgressPolicy;
303
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;
304
325
  }
305
326
  interface PieceModuleRef {
306
327
  bundleDir?: string;
307
328
  entryPath?: string;
308
329
  }
309
- interface RunActionRequest extends HostScopedRequest, PieceModuleRef {
330
+ interface RunActionRequest extends HostScopedRequest, PieceModuleRef, ReactorScopedRequest {
310
331
  actionName: string;
311
332
  propsValue: Record<string, unknown>;
312
333
  auth?: unknown;
313
334
  stagingDir?: string;
335
+ uploadFiles?: boolean;
314
336
  stagedInputs?: StagedInput[];
315
337
  connections?: Record<string, unknown>;
316
338
  storeScope?: string;
@@ -318,12 +340,15 @@ interface RunActionRequest extends HostScopedRequest, PieceModuleRef {
318
340
  captureLogs?: boolean;
319
341
  liveOutput?: boolean;
320
342
  executionType?: `${ExecutionType}`;
343
+ canPause?: boolean;
344
+ resumeBaseUrl?: string;
345
+ flows?: HostServerContext;
346
+ resumePayload?: unknown;
321
347
  stepTest?: boolean;
322
348
  identity?: ActionContextIdentity;
323
349
  redactValues?: string[];
324
- reactorAccess?: boolean;
325
350
  }
326
- interface ResolveOptionsRequest extends HostScopedRequest, PieceModuleRef {
351
+ interface ResolveOptionsRequest extends HostScopedRequest, PieceModuleRef, ReactorScopedRequest {
327
352
  actionName: string;
328
353
  kind?: "action" | "trigger";
329
354
  propName: string;
@@ -331,11 +356,11 @@ interface ResolveOptionsRequest extends HostScopedRequest, PieceModuleRef {
331
356
  auth?: unknown;
332
357
  searchValue?: string;
333
358
  projectId?: string;
334
- reactorAccess?: boolean;
359
+ flows?: boolean;
335
360
  }
336
- interface TriggerHookRequest extends HostScopedRequest, PieceModuleRef {
361
+ interface TriggerHookRequest extends HostScopedRequest, PieceModuleRef, ReactorScopedRequest {
337
362
  triggerName: string;
338
- hook: "onEnable" | "onDisable" | "run" | "test" | "onHandshake" | "onRenew";
363
+ hook: "onEnable" | "onDisable" | "run" | "test" | "onHandshake" | "onRenew" | "onStart";
339
364
  propsValue: Record<string, unknown>;
340
365
  auth?: unknown;
341
366
  storeState?: Record<string, unknown>;
@@ -345,6 +370,7 @@ interface TriggerHookRequest extends HostScopedRequest, PieceModuleRef {
345
370
  payload?: unknown;
346
371
  webhookUrl?: string;
347
372
  server?: ServerContext;
373
+ flows?: HostServerContext;
348
374
  redactValues?: string[];
349
375
  }
350
376
  interface CheckConnectionRequest extends HostScopedRequest, PieceModuleRef {
@@ -354,6 +380,26 @@ interface DescribePieceRequest extends HostScopedRequest, PieceModuleRef {
354
380
  packageName: string;
355
381
  version: string;
356
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
+ }
357
403
  type HostCallHandlers = Record<string, (payload: unknown) => Promise<unknown>>;
358
404
  type HostNotifyHandlers = Record<string, (payload: unknown) => void>;
359
405
  interface PieceLogEntry {
@@ -361,6 +407,40 @@ interface PieceLogEntry {
361
407
  message: string;
362
408
  at: number;
363
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
+ };
364
444
  //#endregion
365
445
  //#region src/pieces/activepieces/resolver.d.ts
366
446
  interface ResolvedPiece extends PieceModuleRef {
@@ -410,121 +490,18 @@ interface IPieceWorkerTransport {
410
490
  }
411
491
  type PieceWorkerTransportFactory = () => IPieceWorkerTransport;
412
492
  //#endregion
413
- //#region src/pieces/activepieces/worker/host.d.ts
414
- interface PieceWorkerResult {
415
- output: unknown;
416
- touched: string[];
417
- tlsPoisoned: boolean;
418
- files?: StagedFile[];
419
- storeState?: Record<string, unknown>;
420
- schedules?: RecordedSchedule[];
421
- listeners?: RecordedListener[];
422
- }
423
- interface RequestTaps {
424
- hostCalls?: HostCallHandlers;
425
- notifications?: HostNotifyHandlers;
426
- }
427
- interface RequestOptions extends RequestTaps {
428
- timeoutMs?: number;
429
- }
430
- interface PieceWorkerOptions {
431
- entryPath?: string;
432
- defaultTimeoutMs?: number;
433
- transport?: PieceWorkerTransportFactory;
434
- }
435
- interface IPieceWorker {
436
- runAction(request: RunActionRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
437
- resolveOptions(request: ResolveOptionsRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
438
- checkConnection(request: CheckConnectionRequest, options?: {
439
- timeoutMs?: number;
440
- }): Promise<PieceWorkerResult>;
441
- describePiece(request: DescribePieceRequest, options?: {
442
- timeoutMs?: number;
443
- }): Promise<PieceWorkerResult>;
444
- runTriggerHook(request: TriggerHookRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
445
- dispose(): void;
446
- }
447
- declare class PieceWorker implements IPieceWorker {
448
- private readonly connect;
449
- private readonly defaultTimeoutMs;
450
- private worker;
451
- private queue;
452
- private nextId;
453
- constructor(options?: PieceWorkerOptions);
454
- runAction(request: RunActionRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
455
- resolveOptions(request: ResolveOptionsRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
456
- checkConnection(request: CheckConnectionRequest, options?: {
457
- timeoutMs?: number;
458
- }): Promise<PieceWorkerResult>;
459
- describePiece(request: DescribePieceRequest, options?: {
460
- timeoutMs?: number;
461
- }): Promise<PieceWorkerResult>;
462
- runTriggerHook(request: TriggerHookRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
463
- private enqueue;
464
- dispose(): void;
465
- private spawn;
466
- private execute;
467
- private serveHostCall;
468
- }
469
- //#endregion
470
- //#region src/pieces/activepieces/worker/pool.d.ts
471
- interface PieceWorkerPoolOptions extends PieceWorkerOptions {
472
- size?: number;
473
- maxQueueDepth?: number;
474
- createWorker?: (options: PieceWorkerOptions) => IPieceWorker;
475
- }
476
- declare class PieceWorkerSession implements IPieceWorker {
477
- private readonly pool;
478
- private worker;
479
- private taking;
480
- private held;
481
- private closed;
482
- constructor(pool: PieceWorkerPool);
483
- runAction(request: RunActionRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
484
- resolveOptions(request: ResolveOptionsRequest, options?: {
485
- timeoutMs?: number;
486
- }): Promise<PieceWorkerResult>;
487
- checkConnection(request: CheckConnectionRequest, options?: {
488
- timeoutMs?: number;
489
- }): Promise<PieceWorkerResult>;
490
- describePiece(request: DescribePieceRequest, options?: {
491
- timeoutMs?: number;
492
- }): Promise<PieceWorkerResult>;
493
- runTriggerHook(request: TriggerHookRequest, options?: RequestOptions): Promise<PieceWorkerResult>;
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;
494
497
  close(): void;
495
- dispose(): void;
496
- private request;
497
- private take;
498
- private acquire;
499
- private giveBack;
500
498
  }
501
- declare class PieceWorkerPool {
502
- readonly size: number;
503
- private readonly maxQueueDepth;
504
- private readonly createWorker;
505
- private readonly workerOptions;
506
- private readonly sessions;
507
- private readonly waiters;
508
- private inUse;
509
- private disposed;
510
- constructor(options?: PieceWorkerPoolOptions);
511
- session(): PieceWorkerSession;
512
- stats(): {
513
- size: number;
514
- active: number;
515
- waiting: number;
516
- };
517
- dispose(): void;
518
- /** @internal — a session taking its slot. */
519
- acquire(session: PieceWorkerSession): Promise<void>;
520
- /** @internal — a session that closed while queueing. */
521
- cancel(session: PieceWorkerSession): void;
522
- /** @internal — a session giving its slot back. */
523
- release(): void;
524
- /** @internal — one child for one session. */
525
- build(): IPieceWorker;
526
- /** @internal — a session that closed itself. */
527
- forget(session: PieceWorkerSession): void;
499
+ interface ReactorTap {
500
+ requireReactor: ReactorRequestBinding["requireReactor"];
501
+ open(transport: ReactorRpcTransport, request: {
502
+ requestId: string;
503
+ deadline: number;
504
+ }): () => void;
528
505
  }
529
506
  //#endregion
530
507
  //#region src/pieces/engine/types.d.ts
@@ -539,6 +516,7 @@ interface WorkflowTriggerDef {
539
516
  pieceVersion: string;
540
517
  triggerName: string;
541
518
  connectionId?: string | null;
519
+ reactorConnectionId?: string | null;
542
520
  config?: unknown;
543
521
  propertySettings?: PropertySettingDef[] | null;
544
522
  }
@@ -550,10 +528,12 @@ interface WorkflowStepDef {
550
528
  pieceVersion: string;
551
529
  actionName: string;
552
530
  connectionId?: string | null;
531
+ reactorConnectionId?: string | null;
553
532
  config: unknown;
554
533
  timeoutSeconds?: number | null;
555
534
  propertySettings?: PropertySettingDef[] | null;
556
535
  skip?: boolean | null;
536
+ retry?: unknown;
557
537
  }
558
538
  interface WorkflowEdgeDef {
559
539
  id: string;
@@ -577,58 +557,353 @@ interface BlockExecution {
577
557
  block: BlockRef;
578
558
  config: unknown;
579
559
  connectionId?: string | null;
560
+ reactorConnectionId?: string | null;
580
561
  step: WorkflowStepDef;
581
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;
582
601
  }
583
602
  interface BlockResult {
584
603
  output: unknown;
585
604
  port?: string;
586
605
  redactValues?: string[];
587
606
  resolution?: BlockResolution;
607
+ paused?: {
608
+ waitpointId: string;
609
+ };
610
+ response?: RunResponse;
611
+ stopped?: boolean;
588
612
  }
589
613
  interface BlockExecutor {
590
614
  execute(execution: BlockExecution): Promise<BlockResult>;
591
615
  }
592
- type StepExecutionStatus = "SUCCEEDED" | "FAILED" | "SKIPPED" | "REPLAYED";
616
+ type StepExecutionStatus = "WAITING" | "SUCCEEDED" | "FAILED" | "SKIPPED" | "REPLAYED" | "INDETERMINATE";
593
617
  interface StepExecutionRecord {
594
618
  stepId: string;
619
+ path?: string;
595
620
  key: string;
596
621
  pieceName: string;
597
622
  blockName: string;
598
623
  status: StepExecutionStatus;
599
624
  input?: unknown;
600
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;
601
637
  port?: string;
602
638
  error?: string;
639
+ errorName?: string;
603
640
  startedAt?: string;
604
641
  endedAt?: string;
605
642
  piece?: StepPieceRecord;
606
643
  configHash?: string;
644
+ attempts?: number;
645
+ carried?: boolean;
607
646
  }
608
- type WorkflowRunStatus = "SUCCEEDED" | "FAILED";
647
+ type WorkflowRunStatus = "SUCCEEDED" | "FAILED" | "CANCELLED" | "WAITING";
609
648
  interface WorkflowRunResult {
610
649
  status: WorkflowRunStatus;
611
650
  steps: StepExecutionRecord[];
612
651
  error?: string;
652
+ errorName?: string;
613
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;
614
880
  }
615
881
  //#endregion
616
882
  //#region src/pieces/engine/secrets.d.ts
883
+ interface SecretOwner {
884
+ documentId: string;
885
+ kind: "connection" | "workflow";
886
+ }
617
887
  interface SecretProvider {
618
- get(ref: string): Promise<string>;
888
+ get(ref: string, owner: SecretOwner): Promise<string>;
619
889
  }
620
890
  interface SecretStat {
621
891
  ref: string;
622
892
  label: string | null;
893
+ ownerId: string | null;
894
+ createdBy: string | null;
623
895
  version: number;
624
896
  status: "ACTIVE" | "DELETED";
625
897
  createdAt: string;
626
898
  updatedAt: string;
627
899
  }
628
900
  interface SecretStore extends SecretProvider {
901
+ get(ref: string, owner: SecretOwner | null): Promise<string>;
629
902
  create(input: {
630
903
  value: string;
631
904
  label?: string;
905
+ ownerId: string | null;
906
+ createdBy?: string | null;
632
907
  }): Promise<SecretStat>;
633
908
  rotate(ref: string, value: string): Promise<SecretStat>;
634
909
  stat(ref: string): Promise<SecretStat>;
@@ -682,25 +957,46 @@ declare class StaticConnectionResolver implements EngineConnectionResolver {
682
957
  resolveWithSecrets(connectionId: string): Promise<ResolvedConnection>;
683
958
  }
684
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
685
981
  //#region src/pieces/engine/blocks.d.ts
686
982
  interface AttachmentPort {
687
- read(ref: string, destPath: string): Promise<{
983
+ read(ref: string, destPath: string, signal?: AbortSignal): Promise<{
688
984
  fileName?: string;
689
985
  contentType?: string;
690
986
  }>;
987
+ authorize?(ref: string): Promise<void>;
691
988
  write(file: {
692
989
  path: string;
693
990
  fileName: string;
694
991
  size: number;
695
992
  contentType?: string;
696
- }): Promise<string>;
993
+ }, signal?: AbortSignal): Promise<string>;
697
994
  }
698
995
  interface PieceStorePort {
699
996
  get(key: string, scope: StoreScopeName): Promise<unknown>;
700
997
  put(key: string, value: unknown, scope: StoreScopeName): Promise<void>;
701
998
  delete(key: string, scope: StoreScopeName): Promise<void>;
702
999
  }
703
- type ReactorPort = ReactorService;
704
1000
  interface ActivepiecesBlockExecutorOptions {
705
1001
  cacheDir: string;
706
1002
  resolveBlock?: (block: BlockRef) => Promise<BlockResolution>;
@@ -709,14 +1005,29 @@ interface ActivepiecesBlockExecutorOptions {
709
1005
  defaultTimeoutMs?: number;
710
1006
  stagingRoot?: string;
711
1007
  attachments?: AttachmentPort;
1008
+ attachmentCache?: AttachmentCache;
712
1009
  pieceStore?: PieceStorePort;
713
1010
  resolver?: PieceResolver;
714
- reactor?: ReactorPort;
1011
+ reactorAccess?: (request: StepReactorRequest) => Promise<ReactorTap | undefined>;
715
1012
  egress?: EgressPolicy | null;
716
1013
  onPieceLog?: (entry: PieceLogEntry, execution: BlockExecution) => void;
717
1014
  onPartialOutput?: (output: unknown, execution: BlockExecution) => void;
718
1015
  identity?: () => Omit<ActionContextIdentity, "stepName"> | undefined;
719
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;
720
1031
  }
721
1032
  declare class ActivepiecesBlockExecutor implements BlockExecutor {
722
1033
  private readonly options;
@@ -725,9 +1036,13 @@ declare class ActivepiecesBlockExecutor implements BlockExecutor {
725
1036
  constructor(options: ActivepiecesBlockExecutorOptions);
726
1037
  private worker;
727
1038
  execute(execution: BlockExecution): Promise<BlockResult>;
1039
+ private builtinOptions;
728
1040
  private run;
729
1041
  private resolveConnection;
730
1042
  private stageInputs;
1043
+ private readAttachment;
1044
+ private uploadHandlers;
1045
+ private checkStagedFile;
731
1046
  private ingestFiles;
732
1047
  dispose(): void;
733
1048
  }
@@ -738,19 +1053,73 @@ declare class CompositeBlockExecutor implements BlockExecutor {
738
1053
  execute(execution: BlockExecution): Promise<BlockResult>;
739
1054
  }
740
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
741
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
+ }
742
1102
  interface RunWorkflowOptions {
743
1103
  definition: WorkflowDefinition;
744
1104
  executor: BlockExecutor;
745
1105
  triggerPayload?: unknown;
746
- completedSteps?: Map<string, {
747
- output?: unknown;
748
- port?: string | null;
749
- }>;
1106
+ completedSteps?: Map<string, ReplayedStep>;
1107
+ loopItems?: Map<string, unknown[]>;
1108
+ defaultRetry?: EffectiveRetryPolicy | null;
1109
+ deadline?: number;
1110
+ sleep?: (ms: number) => Promise<void>;
750
1111
  onStep?: (record: StepExecutionRecord, ordinal: number) => void | Promise<void>;
751
1112
  redactValues?: string[];
752
1113
  priorSteps?: ExpressionScope["steps"];
753
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;
754
1123
  }
755
1124
  declare function runWorkflow(options: RunWorkflowOptions): Promise<WorkflowRunResult>;
756
1125
  //#endregion
@@ -766,6 +1135,6 @@ declare class PieceRegistry {
766
1135
  }
767
1136
  declare const packagePieces: PieceRegistry;
768
1137
  //#endregion
769
- export { BlockResolution as A, PieceResolver as C, RecordedSchedule as D, EgressPolicy as E, PieceDescriptor as M, buildDescriptor as N, extractDedupeKey as O, loadPieceFromDir as P, PackagePiece as S, sourcedResolver as T, PieceWorkerPool as _, ActivepiecesBlockExecutor as a, PieceWorkerResult as b, ReactorPort as c, InMemorySecretProvider as d, SecretStore as f, WorkflowRunResult as g, StepExecutionRecord as h, runWorkflow as i, PieceOrigin as j, BlockMatch as k, ConnectionRequest as l, PropertySettingDef as m, packagePieces as n, AttachmentPort as o, BlockExecution as p, CORE_PIECE_NAME$1 as r, CompositeBlockExecutor as s, PieceRegistry as t, StaticConnectionResolver as u, IPieceWorker as v, PieceTarget as w, LocalPiece as x, PieceWorker as y };
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 };
770
1139
  export {};
771
- //# sourceMappingURL=piece-registry-ohYcOXd-.d.ts.map
1140
+ //# sourceMappingURL=piece-registry-dvS95c3E.d.ts.map