@powerhousedao/reactor-workflow 6.2.3-dev.48 → 6.2.3-dev.50

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,8 @@
1
1
  import { ActionBase, 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 { Readable } from "node:stream";
3
4
  import { BlockIdentity, BlockKind, BlockRef } from "@powerhousedao/pieces-framework/block-type";
5
+ import { Attributes, Context, Meter, Span, Tracer } from "@opentelemetry/api";
4
6
  //#region src/pieces/activepieces/types.d.ts
5
7
  type ApPropertyType = string;
6
8
  type ApDropdownOption = Pick<DropdownOption<unknown>, "label" | "value"> & Partial<Pick<DropdownOption<unknown>, "description" | "icon">>;
@@ -13,6 +15,7 @@ type ApProperty = Partial<Pick<BasePropertySchema, "displayName" | "description"
13
15
  defaultValue?: unknown;
14
16
  options?: ApStaticDropdownState | ((...args: unknown[]) => unknown);
15
17
  props?: (...args: unknown[]) => unknown;
18
+ streaming?: boolean;
16
19
  properties?: Record<string, ApProperty>;
17
20
  width?: string;
18
21
  icon?: string;
@@ -295,6 +298,7 @@ interface StagedInput {
295
298
  path: string;
296
299
  fileName?: string;
297
300
  contentType?: string;
301
+ error?: string;
298
302
  }
299
303
  interface EgressPolicy {
300
304
  allowHosts?: string[];
@@ -366,6 +370,19 @@ interface DescribePieceRequest extends HostScopedRequest, PieceModuleRef {
366
370
  packageName: string;
367
371
  version: string;
368
372
  }
373
+ interface WorkerPhaseTiming {
374
+ name: string;
375
+ start: number;
376
+ end: number;
377
+ parent?: string;
378
+ attributes?: Record<string, string | boolean>;
379
+ }
380
+ interface WorkerTimings {
381
+ received: number;
382
+ sent: number;
383
+ phases: WorkerPhaseTiming[];
384
+ ready?: number;
385
+ }
369
386
  type HostCallHandlers = Record<string, (payload: unknown) => Promise<unknown>>;
370
387
  type HostNotifyHandlers = Record<string, (payload: unknown) => void>;
371
388
  interface PieceLogEntry {
@@ -436,6 +453,143 @@ interface ReactorTap {
436
453
  }): () => void;
437
454
  }
438
455
  //#endregion
456
+ //#region src/pieces/engine/types.d.ts
457
+ interface PropertySettingDef {
458
+ prop: string;
459
+ mode?: string;
460
+ schema?: unknown;
461
+ }
462
+ interface WorkflowTriggerDef {
463
+ id: string;
464
+ pieceName: string;
465
+ pieceVersion: string;
466
+ triggerName: string;
467
+ connectionId?: string | null;
468
+ reactorConnectionId?: string | null;
469
+ config?: unknown;
470
+ propertySettings?: PropertySettingDef[] | null;
471
+ }
472
+ interface WorkflowStepDef {
473
+ id: string;
474
+ key: string;
475
+ name?: string;
476
+ pieceName: string;
477
+ pieceVersion: string;
478
+ actionName: string;
479
+ connectionId?: string | null;
480
+ reactorConnectionId?: string | null;
481
+ config: unknown;
482
+ timeoutSeconds?: number | null;
483
+ propertySettings?: PropertySettingDef[] | null;
484
+ skip?: boolean | null;
485
+ retry?: unknown;
486
+ }
487
+ interface WorkflowEdgeDef {
488
+ id: string;
489
+ from: string;
490
+ to: string;
491
+ port: string;
492
+ condition?: string | null;
493
+ }
494
+ interface WorkflowVariableDef {
495
+ key: string;
496
+ value?: unknown;
497
+ }
498
+ interface WorkflowDefinition {
499
+ name?: string;
500
+ trigger?: WorkflowTriggerDef | null;
501
+ steps: WorkflowStepDef[];
502
+ edges: WorkflowEdgeDef[];
503
+ variables?: WorkflowVariableDef[];
504
+ }
505
+ interface BlockExecution {
506
+ block: BlockRef;
507
+ config: unknown;
508
+ connectionId?: string | null;
509
+ reactorConnectionId?: string | null;
510
+ step: WorkflowStepDef;
511
+ redactValues?: string[];
512
+ }
513
+ interface BlockResult {
514
+ output: unknown;
515
+ port?: string;
516
+ redactValues?: string[];
517
+ resolution?: BlockResolution;
518
+ }
519
+ interface BlockExecutor {
520
+ execute(execution: BlockExecution): Promise<BlockResult>;
521
+ }
522
+ type StepExecutionStatus = "SUCCEEDED" | "FAILED" | "SKIPPED" | "REPLAYED" | "INDETERMINATE";
523
+ interface StepExecutionRecord {
524
+ stepId: string;
525
+ key: string;
526
+ pieceName: string;
527
+ blockName: string;
528
+ status: StepExecutionStatus;
529
+ input?: unknown;
530
+ output?: unknown;
531
+ /**
532
+ * Journaled in the output column in place of `output`, when there is no
533
+ * output to hand a caller but the row still has to say something.
534
+ *
535
+ * One use today: a REPLAYED step whose journaled output the payload cap
536
+ * truncated. The record's `output` stays absent — a caller must not be
537
+ * handed a marker where real data goes — while the row keeps the marker, so
538
+ * a SECOND rerun still knows the output is gone and tells a downstream step
539
+ * by name instead of resolving it to nothing.
540
+ */
541
+ journaledOutput?: unknown;
542
+ port?: string;
543
+ error?: string;
544
+ errorName?: string;
545
+ startedAt?: string;
546
+ endedAt?: string;
547
+ piece?: StepPieceRecord;
548
+ configHash?: string;
549
+ attempts?: number;
550
+ }
551
+ type WorkflowRunStatus = "SUCCEEDED" | "FAILED" | "CANCELLED";
552
+ interface WorkflowRunResult {
553
+ status: WorkflowRunStatus;
554
+ steps: StepExecutionRecord[];
555
+ error?: string;
556
+ errorName?: string;
557
+ warnings?: string[];
558
+ }
559
+ //#endregion
560
+ //#region src/telemetry.d.ts
561
+ declare const TELEMETRY_SCOPE = "@powerhousedao/reactor-workflow";
562
+ interface WorkflowTelemetryOptions {
563
+ tracer?: Tracer;
564
+ meter?: Meter;
565
+ }
566
+ interface WorkerPoolStats {
567
+ size: number;
568
+ active: number;
569
+ waiting: number;
570
+ }
571
+ declare class WorkflowTelemetry {
572
+ readonly tracer: Tracer;
573
+ private readonly meter;
574
+ private readonly runs;
575
+ private readonly runDuration;
576
+ private readonly stepDuration;
577
+ private readonly phaseDuration;
578
+ private poolGauges?;
579
+ constructor(options?: WorkflowTelemetryOptions);
580
+ phase<T>(name: string, attributes: Attributes, fn: (span: Span) => Promise<T>, parent?: Context): Promise<T>;
581
+ workerTimings(request: Span, timings: WorkerTimings, forkedAt: number, ipc: {
582
+ sent: number;
583
+ received: number;
584
+ }): void;
585
+ recordPhase(name: string, ms: number): void;
586
+ span<T>(name: string, attributes: Attributes, fn: (span: Span) => Promise<T>, parent?: Context): Promise<T>;
587
+ recordRun(ms: number, status: string, triggerKind: string): void;
588
+ recordStep(ms: number, pieceName: string, status: string): void;
589
+ observeWorkerPool(stats: () => WorkerPoolStats): () => void;
590
+ private createPoolGauges;
591
+ }
592
+ //#endregion
439
593
  //#region src/pieces/activepieces/worker/host.d.ts
440
594
  interface PieceWorkerResult {
441
595
  output: unknown;
@@ -453,6 +607,7 @@ interface RequestTaps {
453
607
  }
454
608
  interface RequestOptions extends RequestTaps {
455
609
  timeoutMs?: number;
610
+ hostCallTimeoutMs?: number;
456
611
  }
457
612
  interface ModelManifestSource {
458
613
  entries(): unknown[];
@@ -460,6 +615,7 @@ interface ModelManifestSource {
460
615
  }
461
616
  interface PieceWorkerOptions {
462
617
  entryPath?: string;
618
+ telemetry?: WorkflowTelemetry;
463
619
  defaultTimeoutMs?: number;
464
620
  transport?: PieceWorkerTransportFactory;
465
621
  hostCallTimeoutMs?: number;
@@ -482,7 +638,9 @@ declare class PieceWorker implements IPieceWorker {
482
638
  private readonly defaultTimeoutMs;
483
639
  private readonly hostCallTimeoutMs;
484
640
  private readonly models;
641
+ private readonly telemetry;
485
642
  private worker;
643
+ private forkedAt;
486
644
  private queue;
487
645
  private nextId;
488
646
  constructor(options?: PieceWorkerOptions);
@@ -538,6 +696,8 @@ declare class PieceWorkerSession implements IPieceWorker {
538
696
  }
539
697
  declare class PieceWorkerPool {
540
698
  readonly size: number;
699
+ /** @internal */
700
+ readonly telemetry: WorkflowTelemetry | undefined;
541
701
  private readonly maxQueueDepth;
542
702
  private readonly createWorker;
543
703
  private readonly workerOptions;
@@ -565,97 +725,6 @@ declare class PieceWorkerPool {
565
725
  forget(session: PieceWorkerSession): void;
566
726
  }
567
727
  //#endregion
568
- //#region src/pieces/engine/types.d.ts
569
- interface PropertySettingDef {
570
- prop: string;
571
- mode?: string;
572
- schema?: unknown;
573
- }
574
- interface WorkflowTriggerDef {
575
- id: string;
576
- pieceName: string;
577
- pieceVersion: string;
578
- triggerName: string;
579
- connectionId?: string | null;
580
- reactorConnectionId?: string | null;
581
- config?: unknown;
582
- propertySettings?: PropertySettingDef[] | null;
583
- }
584
- interface WorkflowStepDef {
585
- id: string;
586
- key: string;
587
- name?: string;
588
- pieceName: string;
589
- pieceVersion: string;
590
- actionName: string;
591
- connectionId?: string | null;
592
- reactorConnectionId?: string | null;
593
- config: unknown;
594
- timeoutSeconds?: number | null;
595
- propertySettings?: PropertySettingDef[] | null;
596
- skip?: boolean | null;
597
- }
598
- interface WorkflowEdgeDef {
599
- id: string;
600
- from: string;
601
- to: string;
602
- port: string;
603
- condition?: string | null;
604
- }
605
- interface WorkflowVariableDef {
606
- key: string;
607
- value?: unknown;
608
- }
609
- interface WorkflowDefinition {
610
- name?: string;
611
- trigger?: WorkflowTriggerDef | null;
612
- steps: WorkflowStepDef[];
613
- edges: WorkflowEdgeDef[];
614
- variables?: WorkflowVariableDef[];
615
- }
616
- interface BlockExecution {
617
- block: BlockRef;
618
- config: unknown;
619
- connectionId?: string | null;
620
- reactorConnectionId?: string | null;
621
- step: WorkflowStepDef;
622
- redactValues?: string[];
623
- }
624
- interface BlockResult {
625
- output: unknown;
626
- port?: string;
627
- redactValues?: string[];
628
- resolution?: BlockResolution;
629
- }
630
- interface BlockExecutor {
631
- execute(execution: BlockExecution): Promise<BlockResult>;
632
- }
633
- type StepExecutionStatus = "SUCCEEDED" | "FAILED" | "SKIPPED" | "REPLAYED";
634
- interface StepExecutionRecord {
635
- stepId: string;
636
- key: string;
637
- pieceName: string;
638
- blockName: string;
639
- status: StepExecutionStatus;
640
- input?: unknown;
641
- output?: unknown;
642
- port?: string;
643
- error?: string;
644
- errorName?: string;
645
- startedAt?: string;
646
- endedAt?: string;
647
- piece?: StepPieceRecord;
648
- configHash?: string;
649
- }
650
- type WorkflowRunStatus = "SUCCEEDED" | "FAILED";
651
- interface WorkflowRunResult {
652
- status: WorkflowRunStatus;
653
- steps: StepExecutionRecord[];
654
- error?: string;
655
- errorName?: string;
656
- warnings?: string[];
657
- }
658
- //#endregion
659
728
  //#region src/pieces/engine/secrets.d.ts
660
729
  interface SecretProvider {
661
730
  get(ref: string): Promise<string>;
@@ -725,18 +794,40 @@ declare class StaticConnectionResolver implements EngineConnectionResolver {
725
794
  resolveWithSecrets(connectionId: string): Promise<ResolvedConnection>;
726
795
  }
727
796
  //#endregion
797
+ //#region src/pieces/engine/attachment-cache.d.ts
798
+ interface CachedAttachmentMeta {
799
+ fileName?: string;
800
+ contentType?: string;
801
+ size: number;
802
+ }
803
+ interface AttachmentCacheOptions {
804
+ dir: string;
805
+ maxBytes: number;
806
+ }
807
+ declare class AttachmentCache {
808
+ private readonly options;
809
+ constructor(options: AttachmentCacheOptions);
810
+ private entry;
811
+ static cacheable(ref: string): boolean;
812
+ get(ref: string, destPath: string): Promise<CachedAttachmentMeta | undefined>;
813
+ put(ref: string, srcPath: string, meta: Omit<CachedAttachmentMeta, "size">): Promise<void>;
814
+ private remove;
815
+ private evict;
816
+ }
817
+ //#endregion
728
818
  //#region src/pieces/engine/blocks.d.ts
729
819
  interface AttachmentPort {
730
- read(ref: string, destPath: string): Promise<{
820
+ read(ref: string, destPath: string, signal?: AbortSignal): Promise<{
731
821
  fileName?: string;
732
822
  contentType?: string;
733
823
  }>;
824
+ authorize?(ref: string): Promise<void>;
734
825
  write(file: {
735
826
  path: string;
736
827
  fileName: string;
737
828
  size: number;
738
829
  contentType?: string;
739
- }): Promise<string>;
830
+ }, signal?: AbortSignal): Promise<string>;
740
831
  }
741
832
  interface PieceStorePort {
742
833
  get(key: string, scope: StoreScopeName): Promise<unknown>;
@@ -751,6 +842,7 @@ interface ActivepiecesBlockExecutorOptions {
751
842
  defaultTimeoutMs?: number;
752
843
  stagingRoot?: string;
753
844
  attachments?: AttachmentPort;
845
+ attachmentCache?: AttachmentCache;
754
846
  pieceStore?: PieceStorePort;
755
847
  resolver?: PieceResolver;
756
848
  reactorAccess?: (request: StepReactorRequest) => Promise<ReactorTap | undefined>;
@@ -759,6 +851,7 @@ interface ActivepiecesBlockExecutorOptions {
759
851
  onPartialOutput?: (output: unknown, execution: BlockExecution) => void;
760
852
  identity?: () => Omit<ActionContextIdentity, "stepName"> | undefined;
761
853
  stepTest?: () => boolean;
854
+ telemetry?: WorkflowTelemetry;
762
855
  }
763
856
  interface StepReactorRequest {
764
857
  block: ParsedBlockType;
@@ -781,6 +874,8 @@ declare class ActivepiecesBlockExecutor implements BlockExecutor {
781
874
  private run;
782
875
  private resolveConnection;
783
876
  private stageInputs;
877
+ private readAttachment;
878
+ private checkStagedFile;
784
879
  private ingestFiles;
785
880
  dispose(): void;
786
881
  }
@@ -791,15 +886,53 @@ declare class CompositeBlockExecutor implements BlockExecutor {
791
886
  execute(execution: BlockExecution): Promise<BlockResult>;
792
887
  }
793
888
  //#endregion
889
+ //#region src/pieces/engine/retry.d.ts
890
+ type BackoffKind = "FIXED" | "EXPONENTIAL";
891
+ /** A retry policy with every field resolved; `maxAttempts` is already clamped. */
892
+ interface EffectiveRetryPolicy {
893
+ maxAttempts: number;
894
+ backoff: BackoffKind;
895
+ initialDelaySeconds: number;
896
+ maxDelaySeconds: number;
897
+ /** Empty means every error is retryable; see {@link isRetryableError}. */
898
+ retryOn: readonly string[];
899
+ }
900
+ //#endregion
794
901
  //#region src/pieces/engine/coordinator.d.ts
902
+ /** One step a prior run already completed, as a rerun replays it. */
903
+ interface ReplayedStep {
904
+ output?: unknown;
905
+ port?: string | null;
906
+ /**
907
+ * The step SUCCEEDED, but the run journal truncated its output past the
908
+ * payload cap, so there is nothing to replay.
909
+ *
910
+ * It still replays, rather than running again: the step had side effects and
911
+ * re-running it would charge the card twice (backlog item 15). Its scope
912
+ * entry carries an unavailable value instead of data, so a downstream step
913
+ * that reads `steps.<key>.output…` fails the rerun by name.
914
+ */
915
+ outputTruncated?: boolean;
916
+ /**
917
+ * What the journal holds in place of that output — the truncation marker
918
+ * itself — to be journaled again on this run's REPLAYED row.
919
+ *
920
+ * Opaque to the engine: it is never resolved, only written back. Without it
921
+ * the REPLAYED row's output is NULL, and the NEXT rerun reads a NULL as an
922
+ * ordinary replay with no output: the truncation fact is gone after one
923
+ * generation, and a downstream step is handed nothing instead of being told
924
+ * by name why there is nothing.
925
+ */
926
+ truncatedOutput?: unknown;
927
+ }
795
928
  interface RunWorkflowOptions {
796
929
  definition: WorkflowDefinition;
797
930
  executor: BlockExecutor;
798
931
  triggerPayload?: unknown;
799
- completedSteps?: Map<string, {
800
- output?: unknown;
801
- port?: string | null;
802
- }>;
932
+ completedSteps?: Map<string, ReplayedStep>;
933
+ defaultRetry?: EffectiveRetryPolicy | null;
934
+ deadline?: number;
935
+ sleep?: (ms: number) => Promise<void>;
803
936
  onStep?: (record: StepExecutionRecord, ordinal: number) => void | Promise<void>;
804
937
  redactValues?: string[];
805
938
  priorSteps?: ExpressionScope["steps"];
@@ -819,6 +952,6 @@ declare class PieceRegistry {
819
952
  }
820
953
  declare const packagePieces: PieceRegistry;
821
954
  //#endregion
822
- export { BlockMatch as A, PackagePiece as C, EgressPolicy as D, sourcedResolver as E, loadPieceFromDir as F, PieceOrigin as M, PieceDescriptor as N, RecordedSchedule as O, buildDescriptor as P, LocalPiece as S, PieceTarget as T, IPieceWorker as _, ActivepiecesBlockExecutor as a, PieceWorkerResult as b, ConnectionRequest as c, SecretStore as d, BlockExecution as f, PieceWorkerPool as g, WorkflowRunResult as h, runWorkflow as i, BlockResolution as j, extractDedupeKey as k, StaticConnectionResolver as l, StepExecutionRecord as m, packagePieces as n, AttachmentPort as o, PropertySettingDef as p, CORE_PIECE_NAME$1 as r, CompositeBlockExecutor as s, PieceRegistry as t, InMemorySecretProvider as u, ModelManifestSource as v, PieceResolver as w, ReactorTap as x, PieceWorker as y };
955
+ export { sourcedResolver as A, StepExecutionRecord as C, PackagePiece as D, LocalPiece as E, BlockResolution as F, PieceOrigin as I, PieceDescriptor as L, RecordedSchedule as M, extractDedupeKey as N, PieceResolver as O, BlockMatch as P, buildDescriptor as R, PropertySettingDef as S, ReactorTap as T, PieceWorkerResult as _, runWorkflow as a, WorkflowTelemetryOptions as b, CompositeBlockExecutor as c, InMemorySecretProvider as d, SecretStore as f, PieceWorker as g, ModelManifestSource as h, ReplayedStep as i, EgressPolicy as j, PieceTarget as k, ConnectionRequest as l, IPieceWorker as m, packagePieces as n, ActivepiecesBlockExecutor as o, PieceWorkerPool as p, CORE_PIECE_NAME$1 as r, AttachmentPort as s, PieceRegistry as t, StaticConnectionResolver as u, TELEMETRY_SCOPE as v, WorkflowRunResult as w, BlockExecution as x, WorkflowTelemetry as y, loadPieceFromDir as z };
823
956
  export {};
824
- //# sourceMappingURL=piece-registry-wQBhKJUl.d.ts.map
957
+ //# sourceMappingURL=piece-registry-Ds8WkewF.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"piece-registry-Ds8WkewF.d.ts","names":[],"sources":["../src/pieces/activepieces/types.ts","../src/pieces/activepieces/loader.ts","../src/pieces/activepieces/unsupported.ts","../src/pieces/activepieces/descriptor.ts","../src/pieces/engine/resolution.ts","../src/pieces/activepieces/context/store-scope.ts","../src/pieces/activepieces/context/files.ts","../src/pieces/activepieces/context/action.ts","../src/pieces/activepieces/context/trigger.ts","../src/pieces/activepieces/worker/protocol.ts","../src/pieces/activepieces/resolver.ts","../src/pieces/activepieces/worker/transport.ts","../src/pieces/activepieces/worker/reactor-rpc.ts","../src/pieces/engine/types.ts","../src/telemetry.ts","../src/pieces/activepieces/worker/host.ts","../src/pieces/activepieces/worker/pool.ts","../src/pieces/engine/secrets.ts","../src/pieces/engine/expressions.ts","../src/pieces/engine/connections.ts","../src/pieces/engine/attachment-cache.ts","../src/pieces/engine/blocks.ts","../src/pieces/engine/retry.ts","../src/pieces/engine/coordinator.ts","../src/reactor/piece-registry.ts"],"mappings":";;;;;;KAiBY;KAEA,mBAAmB,KAC7B,8CAGA,QAAQ,KAAK;KAGH,wBAAwB,KAClC;EAEI,SAAS;;KAIH,aAAa,QACvB,KACE,mFAIF,QAAQ,KAAK;EACX,OAAO;EACP;EACA;EACA,UAAU,6BAA6B;EAEvC,YAAY;EAEZ;EAEA,aAAa,eAAe;EAE5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;;UAIa;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;;KAIU,WAAW,QACrB,KAAK;EAEL,QAAQ,eAAe;EAGvB;EAEA;EACA,iBAAiB;EAEjB;EACA;IACE,iBAAiB;IACjB,oBAAoB;;EAGtB;EAEA;EACA,MAAM,iBAAiB;EAEvB,QAAQ,iBAAiB;;KAKf;KAIA,2BAA2B,QACrC,KAAK;EACD;;KAEM,YAAY,QACtB,KACE;EAIF,OAAO;EAEP;EAEA;EACA;EACA,QAAQ,eAAe;EACvB,iBAAiB;EACjB;EACA,yBAAyB;EAEzB;IAAuB;IAAmB;;EAC1C,YAAY,iBAAiB;EAC7B,aAAa,iBAAiB;EAC9B,WAAW,iBAAiB;EAC5B,OAAO,iBAAiB;EACxB,QAAQ,iBAAiB;EACzB,eAAe,iBAAiB;EAChC,WAAW,iBAAiB;;KAKlB,UAAU,KAAK,4BACzB,QACE,KACE;EAQF;EACA;EAEA,OAAO,aAAa;EAGpB,UAAU,eAAe,mBAAmB,eAAe;EAC3D,WAAW,eAAe,oBAAoB,eAAe;EAC7D,aAAa,iBAAiB;EAC9B,cAAc,iBAAiB;EAC/B,iBAAiB;;;;UCjKJ;EACf,OAAO;EACP;EAEA;;iBA+HoB,iBAAiB,mBAAmB,QAAQ;;;UClIjD;EACf;EACA;EAEA;;UA2Ee;EACf;EACA;;;;UChEe;EACf;EACA;EACA;EAC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,aAAa;EAGb,WAAW;EAGX,iBACE,SAAS,uBACN,QAAQ;EAGb,SAAS;EAGT,cAAc,OAAO,eAAe,WAAW;EAC/C,mBAAmB,iBAAiB,WAAW;EAG/C,iBAAiB,KAAK;EAEtB;EACA,YAAY;;UAGG;EACf,OAAO;EACP;;UAwDe;EACf;EACA;EACA,SAAS;EACT,MAAM;EAEN;;cAgCW,qCAAqC;mBAOnB;UAJrB;mBAES;EAEjB,YAA6B,SAAS;UAK9B;EAaF,QAAQ,WAAW,iBAAiB,QAAQ;UAwBpC;UAyGA;UAeA;UA0CA;UAiCA;UAgCA;EAgCd;;cAQW,kCAAkC;mBAE1B;mBACA;EAFnB,YACmB,QAAQ,eACR,WAAU,eAAe;EAG5C,QAAQ,WAAW,iBAAiB,QAAQ;;;;KClnBlC;;UAGK;EACf;EACA,SAAS;EACT;EACA;;EAEA;;;;;UCmBe;EACf;EACA;;;;;;;;;;EAUA;;;;;;;;;;;EAWA;;UAGe;EACf,YAAY;EACZ,UAAU;EAEV;EAGA,iBAAiB,YAAY;EAI7B,eAAe;EAGf;EAEA,SAAS,eAAe;EAIxB,UACE,QAAQ,qBACR,2BACU;EAEZ;EAGA,aAAa;EAEb,iBAAiB,OAAO;;iBA+DJ,YACpB,SAAS,qBACR,QAAQ;;;cChJE;UACH;EAIR,UAAU,iBAAiB;EAuC3B,SAAM,iBAAmB;EAEzB,WAAW;EAKX,YAAY;;EAOZ;;cAMW,eAAa"}
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as PackagePiece, E as sourcedResolver, F as loadPieceFromDir, N as PieceDescriptor, O as RecordedSchedule, P as buildDescriptor, S as LocalPiece, T as PieceTarget, _ as IPieceWorker, a as ActivepiecesBlockExecutor, f as BlockExecution, g as PieceWorkerPool, h as WorkflowRunResult, i as runWorkflow, k as extractDedupeKey, l as StaticConnectionResolver, o as AttachmentPort, s as CompositeBlockExecutor, t as PieceRegistry, u as InMemorySecretProvider, w as PieceResolver, y as PieceWorker } from "./piece-registry-wQBhKJUl.js";
1
+ import { A as sourcedResolver, D as PackagePiece, E as LocalPiece, L as PieceDescriptor, M as RecordedSchedule, N as extractDedupeKey, O as PieceResolver, R as buildDescriptor, a as runWorkflow, c as CompositeBlockExecutor, d as InMemorySecretProvider, g as PieceWorker, k as PieceTarget, m as IPieceWorker, o as ActivepiecesBlockExecutor, p as PieceWorkerPool, s as AttachmentPort, t as PieceRegistry, u as StaticConnectionResolver, w as WorkflowRunResult, x as BlockExecution, z as loadPieceFromDir } from "./piece-registry-Ds8WkewF.js";
2
2
  //#region src/pieces/activepieces/fetch.d.ts
3
3
  interface FetchPieceBundleOptions {
4
4
  name: string;
package/dist/testing.js CHANGED
@@ -1,4 +1,92 @@
1
- import { R as buildDescriptor, w as extractDedupeKey } from "./reactor-rpc-BqAjCK1p.js";
2
- import { G as ensurePieceBundle, K as fetchPieceBundle, R as PieceWorkerPool, T as StaticConnectionResolver, W as sourcedResolver, f as ActivepiecesBlockExecutor, j as InMemorySecretProvider, o as runWorkflow, p as CompositeBlockExecutor, t as PieceRegistry, z as PieceWorker } from "./piece-registry-e-vFPyTd.js";
3
- import { n as loadPieceFromDir } from "./loader-Gkx6I_Bo.js";
1
+ import { F as InMemorySecretProvider, H as PieceWorkerPool, U as PieceWorker, at as sourcedResolver, dt as ensurePieceBundle, et as extractDedupeKey, ft as fetchPieceBundle, h as CompositeBlockExecutor, k as StaticConnectionResolver, m as ActivepiecesBlockExecutor, ot as buildDescriptor, s as runWorkflow, t as PieceRegistry } from "./piece-registry-BKRLK7Kv.js";
2
+ import { createRequire } from "node:module";
3
+ import { readFileSync, realpathSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ //#region src/pieces/activepieces/loader.ts
7
+ function resolveEntry(pieceDir) {
8
+ const raw = readFileSync(path.join(pieceDir, "package.json"), "utf8");
9
+ const pkg = JSON.parse(raw);
10
+ const dotExport = pkg.exports?.["."];
11
+ const candidates = [];
12
+ if (typeof dotExport === "string") candidates.push(dotExport);
13
+ if (dotExport && typeof dotExport === "object") {
14
+ const cond = dotExport;
15
+ for (const key of [
16
+ "import",
17
+ "require",
18
+ "default"
19
+ ]) {
20
+ const value = cond[key];
21
+ if (typeof value === "string") candidates.push(value);
22
+ }
23
+ }
24
+ candidates.push(pkg.main, pkg.module, "src/index.js", "index.js", "main.js");
25
+ const root = realpathSync(pieceDir);
26
+ const rootWithSep = root + path.sep;
27
+ for (const candidate of candidates) {
28
+ if (!candidate) continue;
29
+ const abs = path.resolve(pieceDir, candidate);
30
+ let real;
31
+ try {
32
+ real = realpathSync(abs);
33
+ } catch {
34
+ continue;
35
+ }
36
+ if (real !== root && !real.startsWith(rootWithSep)) continue;
37
+ return abs;
38
+ }
39
+ throw new Error(`No entry file found for piece bundle at ${pieceDir}`);
40
+ }
41
+ function isRecord(value) {
42
+ return typeof value === "object" && value !== null;
43
+ }
44
+ function findPiece(mod) {
45
+ const candidates = [
46
+ ...Object.values(mod),
47
+ ...isRecord(mod.default) ? Object.values(mod.default) : [],
48
+ mod.default
49
+ ];
50
+ for (const candidate of candidates) if (isRecord(candidate) && candidate.constructor?.name === "Piece") return {
51
+ piece: candidate,
52
+ check: "constructor-name"
53
+ };
54
+ for (const candidate of candidates) if (isRecord(candidate) && typeof candidate.displayName === "string" && (isRecord(candidate.actions) || typeof candidate.actions === "function" || typeof candidate.getAction === "function")) return {
55
+ piece: candidate,
56
+ check: "structural"
57
+ };
58
+ }
59
+ function missingModule(entryPath, error) {
60
+ const code = error?.code;
61
+ if (code !== "ERR_MODULE_NOT_FOUND" && code !== "MODULE_NOT_FOUND") return;
62
+ const detail = error instanceof Error ? error.message : String(error);
63
+ return /* @__PURE__ */ new Error(`Piece at ${entryPath} could not be loaded: it imports a module that is not there. Its dependencies are installed with lifecycle scripts disabled, so one that compiles or downloads on install -- a native addon, a browser download -- cannot be prepared here. ${detail}`);
64
+ }
65
+ async function loadPiece(entryPath) {
66
+ let mod;
67
+ try {
68
+ mod = await import(
69
+ /* @vite-ignore */
70
+ pathToFileURL(entryPath).href
71
+ );
72
+ } catch (imported) {
73
+ try {
74
+ mod = createRequire(import.meta.url)(entryPath);
75
+ } catch (required) {
76
+ throw missingModule(entryPath, imported) ?? missingModule(entryPath, required) ?? required;
77
+ }
78
+ }
79
+ const found = findPiece(mod);
80
+ if (!found) throw new Error(`No Piece export found in ${entryPath}. Export keys: ${Object.keys(mod).join(", ")}`);
81
+ return {
82
+ ...found,
83
+ entryPath
84
+ };
85
+ }
86
+ async function loadPieceFromDir(pieceDir) {
87
+ return loadPiece(resolveEntry(pieceDir));
88
+ }
89
+ //#endregion
4
90
  export { ActivepiecesBlockExecutor, CompositeBlockExecutor, InMemorySecretProvider, PieceRegistry, PieceWorker, PieceWorkerPool, StaticConnectionResolver, buildDescriptor, ensurePieceBundle, extractDedupeKey, fetchPieceBundle, loadPieceFromDir, runWorkflow, sourcedResolver };
91
+
92
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","names":[],"sources":["../src/pieces/activepieces/loader.ts"],"sourcesContent":["import { readFileSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ApPiece } from \"./types.js\";\n\nexport interface LoadedPiece {\n piece: ApPiece;\n entryPath: string;\n // Which duck-type check identified the export.\n check: \"constructor-name\" | \"structural\";\n}\n\n// Resolves a bundle's entry file. Published bundles typically carry only\n// `main` (no `exports`, no `type` — they are CJS).\nexport function resolveEntry(pieceDir: string): string {\n const raw = readFileSync(path.join(pieceDir, \"package.json\"), \"utf8\");\n const pkg = JSON.parse(raw) as {\n main?: string;\n module?: string;\n exports?: Record<string, unknown>;\n };\n const dotExport = pkg.exports?.[\".\"];\n const candidates: (string | undefined)[] = [];\n if (typeof dotExport === \"string\") candidates.push(dotExport);\n if (dotExport && typeof dotExport === \"object\") {\n const cond = dotExport as Record<string, unknown>;\n for (const key of [\"import\", \"require\", \"default\"]) {\n const value = cond[key];\n if (typeof value === \"string\") candidates.push(value);\n }\n }\n candidates.push(pkg.main, pkg.module, \"src/index.js\", \"index.js\", \"main.js\");\n // A bundle's manifest (or a symlink inside it) must not point the entry\n // outside pieceDir; realpath so a symlink can't launder the escape.\n const root = realpathSync(pieceDir);\n const rootWithSep = root + path.sep;\n for (const candidate of candidates) {\n if (!candidate) continue;\n const abs = path.resolve(pieceDir, candidate);\n let real: string;\n try {\n real = realpathSync(abs);\n } catch {\n continue; // candidate doesn't exist; try the next one\n }\n if (real !== root && !real.startsWith(rootWithSep)) continue;\n return abs;\n }\n throw new Error(`No entry file found for piece bundle at ${pieceDir}`);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n// Identify the piece by constructor name (their own loader's check), falling\n// back to structure for bundles minified without keepNames. No `instanceof`.\nfunction findPiece(\n mod: Record<string, unknown>,\n): Pick<LoadedPiece, \"piece\" | \"check\"> | undefined {\n const candidates: unknown[] = [\n ...Object.values(mod),\n ...(isRecord(mod.default) ? Object.values(mod.default) : []),\n mod.default,\n ];\n for (const candidate of candidates) {\n // `constructor?.name`: a bundle may export an Object.create(null), and the\n // real piece is usually beside it in the same module.\n if (isRecord(candidate) && candidate.constructor?.name === \"Piece\") {\n return {\n piece: candidate as unknown as ApPiece,\n check: \"constructor-name\",\n };\n }\n }\n for (const candidate of candidates) {\n if (\n isRecord(candidate) &&\n typeof candidate.displayName === \"string\" &&\n (isRecord(candidate.actions) ||\n typeof candidate.actions === \"function\" ||\n typeof candidate.getAction === \"function\")\n ) {\n return { piece: candidate as unknown as ApPiece, check: \"structural\" };\n }\n }\n return undefined;\n}\n\n// A module the piece names and node cannot find. Dependencies are installed\n// with scripts disabled, so a native or downloaded one looks like this.\nfunction missingModule(entryPath: string, error: unknown): Error | undefined {\n const code = (error as { code?: unknown } | null)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\" && code !== \"MODULE_NOT_FOUND\") {\n return undefined;\n }\n const detail = error instanceof Error ? error.message : String(error);\n return new Error(\n `Piece at ${entryPath} could not be loaded: it imports a module that is ` +\n `not there. Its dependencies are installed with lifecycle scripts ` +\n `disabled, so one that compiles or downloads on install -- a native ` +\n `addon, a browser download -- cannot be prepared here. ${detail}`,\n );\n}\n\n// ESM-first `import()` — Node's CJS interop handles the typical CJS bundle —\n// with a `require` fallback.\nexport async function loadPiece(entryPath: string): Promise<LoadedPiece> {\n let mod: Record<string, unknown>;\n try {\n mod = (await import(\n /* @vite-ignore */ pathToFileURL(entryPath).href\n )) as Record<string, unknown>;\n } catch (imported) {\n try {\n const require = createRequire(import.meta.url);\n mod = require(entryPath) as Record<string, unknown>;\n } catch (required) {\n // The import's error names the missing module; require's often names\n // only the entry it was handed.\n throw (\n missingModule(entryPath, imported) ??\n missingModule(entryPath, required) ??\n required\n );\n }\n }\n const found = findPiece(mod);\n if (!found) {\n throw new Error(\n `No Piece export found in ${entryPath}. Export keys: ${Object.keys(mod).join(\", \")}`,\n );\n }\n return { ...found, entryPath };\n}\n\nexport async function loadPieceFromDir(pieceDir: string): Promise<LoadedPiece> {\n return loadPiece(resolveEntry(pieceDir));\n}\n"],"mappings":";;;;;;AAeA,SAAgB,aAAa,UAA0B;CACrD,MAAM,MAAM,aAAa,KAAK,KAAK,UAAU,cAAc,GAAG,MAAM;CACpE,MAAM,MAAM,KAAK,MAAM,GAAG;CAK1B,MAAM,YAAY,IAAI,UAAU;CAChC,MAAM,aAAqC,CAAC;CAC5C,IAAI,OAAO,cAAc,UAAU,WAAW,KAAK,SAAS;CAC5D,IAAI,aAAa,OAAO,cAAc,UAAU;EAC9C,MAAM,OAAO;EACb,KAAK,MAAM,OAAO;GAAC;GAAU;GAAW;EAAS,GAAG;GAClD,MAAM,QAAQ,KAAK;GACnB,IAAI,OAAO,UAAU,UAAU,WAAW,KAAK,KAAK;EACtD;CACF;CACA,WAAW,KAAK,IAAI,MAAM,IAAI,QAAQ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