@powerhousedao/reactor-workflow 6.2.3-dev.43 → 6.2.3-dev.45

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.
package/README.md CHANGED
@@ -39,8 +39,9 @@ rather than restated here.
39
39
  contexts from `Store`, `ServerContext`, `FilesService`, `ConnectionsManager`,
40
40
  `FlowsContext`, `RunContext`, `TriggerHookContext` and `SetScheduleRequest`;
41
41
  the connection shapes from `AppConnectionType` and `AppConnectionValue`.
42
- `PackagePiece`, `ReactorService` and `DEDUPE_KEY_PROPERTY` are the framework's
43
- own Powerhouse half.
42
+ `PackagePiece`, `RequireReactor`, `ReactorClient`, `ReactorReadClient`, the
43
+ reactor error names and `DEDUPE_KEY_PROPERTY` are the framework's own
44
+ Powerhouse half.
44
45
  - The **enums stay strings here**. A piece bundle inlines its own copy of the
45
46
  framework, so a `PropertyType` or `TriggerStrategy` read off one shares no
46
47
  identity with ours. Every such value is compared as a string; nothing in
@@ -142,6 +143,17 @@ transport finds that child's code by walking up to this package's own
142
143
  `package.json` and reading `dist/worker-entry.js`, so `pnpm build` must have run
143
144
  before anything executes a piece — including the suites here.
144
145
 
146
+ That entry is `src/worker/entry.ts`: the piece worker from `src/pieces`, plus
147
+ `ctx.reactor` (`src/worker/reactor.ts`), which needs `@powerhousedao/reactor`
148
+ and so lives outside the piece layer. For an action, trigger or option resolver
149
+ that declares `requireReactor`, the host serves one `ReactorHostServer` per
150
+ request over the child's IPC channel, as `{ type: "reactor-rpc", requestId,
151
+ message }`; the worker builds a reactor RPC proxy per request and closes it when
152
+ the request settles. The boot document models reach the child on fork as
153
+ `{ type: "model-manifest", entries }`. A type the host loaded later is looked
154
+ up with a `model-entries` host call the first time a piece asks for it. Either
155
+ way the model is imported on first use.
156
+
145
157
  ## Blocks
146
158
 
147
159
  A step names its block the way Activepieces does, with three fields:
@@ -195,7 +207,9 @@ step tests. A block whose version is not an exact semver resolves to `missing`.
195
207
  note). At most five candidates are described per resolution.
196
208
  4. **Host-bound pieces** (`@powerhousedao/piece-core`,
197
209
  `@powerhousedao/piece-reactor`) always run the installed copy, with match
198
- `installed`.
210
+ `installed`. Both ship with this runtime's packages and version with it;
211
+ `piece-reactor` reaches the reactor through `requireReactor` like any
212
+ other piece.
199
213
  5. **Missing** is the only failure: no source has the piece, or none of the
200
214
  candidates described has an action or trigger of that name.
201
215
 
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { A as BlockResolution, C as PieceResolver, E as EgressPolicy, b as PieceWorkerResult, f as SecretStore, g as WorkflowRunResult, h as StepExecutionRecord, j as PieceOrigin, k as BlockMatch, l as ConnectionRequest, m as PropertySettingDef, n as packagePieces, o as AttachmentPort, r as CORE_PIECE_NAME, t as PieceRegistry, y as PieceWorker } from "./piece-registry-Bt1Cd3ly.js";
1
+ import { A as BlockMatch, D as EgressPolicy, M as PieceOrigin, b as PieceWorkerResult, c as ConnectionRequest, d as SecretStore, h as WorkflowRunResult, j as BlockResolution, m as StepExecutionRecord, n as packagePieces, o as AttachmentPort, p as PropertySettingDef, r as CORE_PIECE_NAME, t as PieceRegistry, v as ModelManifestSource, w as PieceResolver, x as ReactorTap, y as PieceWorker } from "./piece-registry-wQBhKJUl.js";
2
2
  import { ActionBase, TriggerBase } from "@powerhousedao/pieces-framework";
3
3
  import { ILogger, OperationWithContext } from "document-model";
4
+ import "@powerhousedao/pieces-framework/workflow";
4
5
  import { BlockIdentity, BlockRef } from "@powerhousedao/pieces-framework/block-type";
5
6
  import "@powerhousedao/workflow/document-models/workflow";
6
- import { BaseReadModel, DocumentViewDatabase, IConsistencyTracker, IOperationIndex, IReactorClient, IWriteCache, ReadModelRegistrationStage } from "@powerhousedao/reactor";
7
- import { AuthSubject } from "@powerhousedao/shared/document-model";
7
+ import { BaseReadModel, DocumentViewDatabase, IConsistencyTracker, IOperationIndex, IReactorClient, IWriteCache, ModelManifestEntry, ReadModelRegistrationStage } from "@powerhousedao/reactor";
8
+ import { AuthSubject, Principal } from "@powerhousedao/shared/document-model";
8
9
  import { IRelationalDb, IWebhookScope, WebhookField, WebhookHashAlgorithm, WebhookPolicy, WebhookReply, WebhookRequest, WebhookSignatureEncoding } from "@powerhousedao/shared/processors";
9
10
  //#region src/pieces/core/version.d.ts
10
11
  export declare const CORE_PIECE_VERSION: string;
@@ -40,12 +41,21 @@ export declare function setPieceRegistryUrl(url: string | undefined): void;
40
41
  //#endregion
41
42
  //#region src/reactor/host.d.ts
42
43
  type WorkflowCaller = object;
44
+ type HostIdentity = {
45
+ address?: string;
46
+ key: string;
47
+ };
43
48
  interface WorkflowRuntimeHostDeps {
44
49
  relationalDb: IRelationalDb;
45
50
  reactorClient: IReactorClient;
46
51
  assertCanRead(identifier: string, caller: WorkflowCaller): Promise<unknown>;
47
52
  assertCanWrite(identifier: string, caller: WorkflowCaller): Promise<unknown>;
48
53
  subjectOf?(caller: WorkflowCaller): AuthSubject;
54
+ authEnforcement?: boolean;
55
+ hostPrincipal?: Principal;
56
+ hostIdentity?: HostIdentity;
57
+ modelManifest?(): ModelManifestEntry[];
58
+ modelEntries?(documentType: string): ModelManifestEntry[];
49
59
  webhooks?: IWebhookScope;
50
60
  attachments?: AttachmentClientLike;
51
61
  canReadAttachmentRef?(documentId: string, ref: string): Promise<boolean>;
@@ -169,6 +179,7 @@ interface StepTestResult {
169
179
  status: "SUCCEEDED" | "FAILED";
170
180
  output?: unknown;
171
181
  error?: string;
182
+ errorName?: string;
172
183
  durationMs: number;
173
184
  }
174
185
  //#endregion
@@ -182,6 +193,7 @@ interface RunRow {
182
193
  trigger_payload: string | null;
183
194
  status: string;
184
195
  error: string | null;
196
+ error_name: string | null;
185
197
  enqueued_at: string;
186
198
  started_at: string;
187
199
  ended_at: string | null;
@@ -202,6 +214,7 @@ interface StepExecutionRow {
202
214
  output: string | null;
203
215
  port: string | null;
204
216
  error: string | null;
217
+ error_name: string | null;
205
218
  started_at: string | null;
206
219
  ended_at: string | null;
207
220
  piece_version: string | null;
@@ -308,7 +321,7 @@ declare class WorkflowRunStore {
308
321
  recordStep(runId: string, ordinal: number, step: StepExecutionRecord): Promise<void>;
309
322
  finishRun(runId: string, result: WorkflowRunResult, executionOrder?: ReadonlyMap<string, number>): Promise<void>;
310
323
  private sweepSteps;
311
- failRun(runId: string, error: string): Promise<void>;
324
+ failRun(runId: string, error: string, errorName?: string): Promise<void>;
312
325
  listRuns(workflowId?: string | string[], limit?: number, options?: ListRunsOptions): Promise<RunRow[]>;
313
326
  getRun(id: string): Promise<RunRow | undefined>;
314
327
  getSteps(runId: string): Promise<StepExecutionRow[]>;
@@ -342,6 +355,25 @@ declare class WorkflowRunStore {
342
355
  deletePieceStore(scope: string, scopeKey: string): Promise<void>;
343
356
  }
344
357
  //#endregion
358
+ //#region src/reactor/run-scope.d.ts
359
+ interface ReactorConnectionScope {
360
+ access: "read" | "write";
361
+ }
362
+ interface RunScope {
363
+ runUser: {
364
+ address: string;
365
+ subject: AuthSubject;
366
+ } | null;
367
+ requireReactor: "read" | "write";
368
+ connection: ReactorConnectionScope;
369
+ deadline: number;
370
+ journal: {
371
+ recordDocuments(documentIds: string[]): Promise<void>;
372
+ recordJob(jobId: string, documentIds: string[]): Promise<void>;
373
+ };
374
+ }
375
+ type RunUser = NonNullable<RunScope["runUser"]>;
376
+ //#endregion
345
377
  //#region src/reactor/trigger-supervisor.d.ts
346
378
  interface PieceTriggerBinding {
347
379
  kind?: "piece";
@@ -352,6 +384,7 @@ interface PieceTriggerBinding {
352
384
  triggerName: string;
353
385
  config: Record<string, unknown>;
354
386
  connectionId?: string | null;
387
+ reactorConnectionId?: string | null;
355
388
  pollIntervalMs?: number;
356
389
  propertySettings?: PropertySettingDef[];
357
390
  source?: PieceOrigin;
@@ -372,6 +405,8 @@ interface TriggerSupervisorOptions {
372
405
  cacheDir: string;
373
406
  resolver?: PieceResolver;
374
407
  worker?: PieceWorker;
408
+ models?: ModelManifestSource;
409
+ reactorAccess?: (binding: PieceTriggerBinding, requireReactor: "read" | "write", runUser: RunUser | null | undefined) => Promise<ReactorTap>;
375
410
  egress?: EgressPolicy | null;
376
411
  tickMs?: number;
377
412
  defaultIntervalMs?: number;
@@ -408,12 +443,17 @@ declare class TriggerSupervisor {
408
443
  private unbind;
409
444
  reject(workflowId: string, block: BlockIdentity, config: unknown, message: string, retryAt?: Date): Promise<void>;
410
445
  private recordRejection;
411
- test(binding: PieceTriggerBinding): Promise<unknown>;
446
+ test(binding: PieceTriggerBinding, options?: {
447
+ runUser?: RunUser | null;
448
+ }): Promise<unknown>;
412
449
  private dropTestPartitions;
413
450
  handshake(binding: PieceTriggerBinding, payload: unknown): Promise<PieceWorkerResult>;
414
451
  deliverWebhook(workflowId: string, payload: unknown): Promise<void>;
415
452
  private cursorRewind;
416
453
  private hook;
454
+ private reactorFor;
455
+ private pieceDescriptor;
456
+ private triggerDescriptor;
417
457
  private deliveryFor;
418
458
  private enable;
419
459
  private renewAtAfterEnable;
@@ -549,6 +589,12 @@ export declare class WorkflowRuntimeService {
549
589
  }): Promise<BlockResolution>;
550
590
  private logResolution;
551
591
  private resolvedPiece;
592
+ private readonly reactorDenials;
593
+ private recheckReactorAccess;
594
+ private checkReactorAccess;
595
+ private seedReactorAccess;
596
+ reactorAccessDenial(workflowId: string): string | undefined;
597
+ private refuseArming;
552
598
  private readonly unarmed;
553
599
  private reportUnarmedTrigger;
554
600
  private readonly resolutionRetries;
@@ -609,6 +655,14 @@ export declare class WorkflowRuntimeService {
609
655
  private pieceHandshakeConfig;
610
656
  private deliverToPiece;
611
657
  private webhookSecret;
658
+ private readonly models;
659
+ private modelEntries;
660
+ private declaredReactor;
661
+ private callerRunUser;
662
+ private reactorScope;
663
+ private stepReactorAccess;
664
+ private triggerReactorAccess;
665
+ private designReactorAccess;
612
666
  private readonly descriptors;
613
667
  private designWorker?;
614
668
  private designEgress;
@@ -657,7 +711,7 @@ export declare class WorkflowRuntimeService {
657
711
  private assertCanReadDocument;
658
712
  private assertCanReadWorkflow;
659
713
  private assertCanWriteDocument;
660
- blockOptions(block: BlockRef, propName: string, input?: unknown, connectionId?: string, ctx?: WorkflowCaller, searchValue?: string): Promise<unknown>;
714
+ blockOptions(block: BlockRef, propName: string, input?: unknown, connectionId?: string, ctx?: WorkflowCaller, searchValue?: string, reactorConnectionId?: string): Promise<unknown>;
661
715
  blockOutputTree(block: BlockRef, config?: unknown): Promise<OutputTree>;
662
716
  private stateFields;
663
717
  private operationInputFields;
@@ -680,8 +734,11 @@ export declare class WorkflowRuntimeService {
680
734
  rerunOf: string;
681
735
  }, ctx?: WorkflowCaller, enqueuedRunId?: string): Promise<PersistedRunResult>;
682
736
  rerun(runId: string, ctx?: WorkflowCaller): Promise<PersistedRunResult>;
737
+ private rereads;
683
738
  testStep(workflowId: string, stepId: string, ctx?: WorkflowCaller, access?: WorkflowAccessOptions): Promise<StepTestResult>;
684
739
  private testScope;
740
+ private readReferencedDocuments;
741
+ private documentShapes;
685
742
  private lastTestSample;
686
743
  stepOutputTree(workflowId: string, stepId: string, ctx?: WorkflowCaller): Promise<OutputTree>;
687
744
  blockResolutions(workflowId: string, ctx?: WorkflowCaller): Promise<BlockResolutionRecord[]>;
@@ -695,6 +752,9 @@ export declare class InvalidRunCursorError extends Error {
695
752
  constructor();
696
753
  }
697
754
  //#endregion
755
+ //#region src/reactor/run-user.d.ts
756
+ export declare function publishRunUser(client: Pick<IReactorClient, "getOperations">, workflowId: string, hostIdentity?: HostIdentity, signal?: AbortSignal): Promise<RunUser | null>;
757
+ //#endregion
698
758
  //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/operation-node/operation-node.d.ts
699
759
  type OperationNodeKind = 'IdentifierNode' | 'SchemableIdentifierNode' | 'RawNode' | 'SelectQueryNode' | 'SelectionNode' | 'ReferenceNode' | 'ColumnNode' | 'TableNode' | 'AliasNode' | 'FromNode' | 'SelectAllNode' | 'AndNode' | 'OrNode' | 'ParensNode' | 'ValueNode' | 'ValueListNode' | 'PrimitiveValueListNode' | 'JoinNode' | 'OperatorNode' | 'WhereNode' | 'InsertQueryNode' | 'DeleteQueryNode' | 'ReturningNode' | 'CreateTableNode' | 'ColumnDefinitionNode' | 'AddColumnNode' | 'DropTableNode' | 'DataTypeNode' | 'OrderByNode' | 'OrderByItemNode' | 'GroupByNode' | 'GroupByItemNode' | 'UpdateQueryNode' | 'ColumnUpdateNode' | 'LimitNode' | 'OffsetNode' | 'OnConflictNode' | 'OnDuplicateKeyNode' | 'CreateIndexNode' | 'DropIndexNode' | 'ListNode' | 'ReferencesNode' | 'PrimaryKeyConstraintNode' | 'UniqueConstraintNode' | 'CheckConstraintNode' | 'ForeignKeyConstraintNode' | 'WithNode' | 'CommonTableExpressionNode' | 'HavingNode' | 'CreateSchemaNode' | 'DropSchemaNode' | 'AlterTableNode' | 'ModifyColumnNode' | 'DropColumnNode' | 'RenameColumnNode' | 'AlterColumnNode' | 'AddConstraintNode' | 'DropConstraintNode' | 'CreateViewNode' | 'RefreshMaterializedViewNode' | 'DropViewNode' | 'GeneratedNode' | 'DefaultValueNode' | 'OnNode' | 'ValuesNode' | 'CommonTableExpressionNameNode' | 'SelectModifierNode' | 'CreateTypeNode' | 'DropTypeNode' | 'ExplainNode' | 'DefaultInsertValueNode' | 'AggregateFunctionNode' | 'OverNode' | 'PartitionByNode' | 'PartitionByItemNode' | 'SetOperationNode' | 'BinaryOperationNode' | 'UnaryOperationNode' | 'UsingNode' | 'FunctionNode' | 'CaseNode' | 'WhenNode' | 'JSONReferenceNode' | 'JSONPathNode' | 'JSONPathLegNode' | 'JSONOperatorChainNode' | 'TupleNode' | 'MergeQueryNode' | 'MatchedNode' | 'AddIndexNode' | 'CastNode' | 'FetchNode' | 'TopNode' | 'OutputNode' | 'OrActionNode' | 'CollateNode' | 'RenameConstraintNode';
700
760
  interface OperationNode {
@@ -19290,6 +19350,6 @@ interface WebhookPayload {
19290
19350
  body: unknown;
19291
19351
  }
19292
19352
  //#endregion
19293
- export { type AttachmentClientLike, type BlockResolutionRecord, CORE_PIECE_NAME, type ConnectionCheckResult, type ConnectionSummary, type OAuthAttemptStatus, type OAuthAttemptView, type OAuthStart, type OutputTree, type OutputTreeNode, type PersistedRunResult, PieceRegistry, type PieceStoreRow, type PieceTriggerBinding, type RunPage, type RunRecord, type RunRow, type RunsArgs, type RunsPageArgs, type ScheduleTriggerBinding, type StepExecutionRow, type StepTestResult, type TriggerBinding, type TriggerDedupeRow, type TriggerStateRow, type WebhookConfig, type WebhookPayload, type WorkflowAccessOptions, type WorkflowCaller, type WorkflowRuntimeDB, type WorkflowRuntimeHostDeps, packagePieces };
19353
+ export { type AttachmentClientLike, type BlockResolutionRecord, CORE_PIECE_NAME, type ConnectionCheckResult, type ConnectionSummary, type HostIdentity, type OAuthAttemptStatus, type OAuthAttemptView, type OAuthStart, type OutputTree, type OutputTreeNode, type PersistedRunResult, PieceRegistry, type PieceStoreRow, type PieceTriggerBinding, type RunPage, type RunRecord, type RunRow, type RunsArgs, type RunsPageArgs, type ScheduleTriggerBinding, type StepExecutionRow, type StepTestResult, type TriggerBinding, type TriggerDedupeRow, type TriggerStateRow, type WebhookConfig, type WebhookPayload, type WorkflowAccessOptions, type WorkflowCaller, type WorkflowRuntimeDB, type WorkflowRuntimeHostDeps, packagePieces };
19294
19354
  export {};
19295
19355
  //# sourceMappingURL=index.d.ts.map