@powerhousedao/reactor-workflow 6.2.3-dev.44 → 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, c as ReactorPort, 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-ChjdczOf.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,8 +405,9 @@ 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
- reactor?: ReactorPort;
377
411
  tickMs?: number;
378
412
  defaultIntervalMs?: number;
379
413
  hookTimeoutMs?: number;
@@ -409,12 +443,17 @@ declare class TriggerSupervisor {
409
443
  private unbind;
410
444
  reject(workflowId: string, block: BlockIdentity, config: unknown, message: string, retryAt?: Date): Promise<void>;
411
445
  private recordRejection;
412
- test(binding: PieceTriggerBinding): Promise<unknown>;
446
+ test(binding: PieceTriggerBinding, options?: {
447
+ runUser?: RunUser | null;
448
+ }): Promise<unknown>;
413
449
  private dropTestPartitions;
414
450
  handshake(binding: PieceTriggerBinding, payload: unknown): Promise<PieceWorkerResult>;
415
451
  deliverWebhook(workflowId: string, payload: unknown): Promise<void>;
416
452
  private cursorRewind;
417
453
  private hook;
454
+ private reactorFor;
455
+ private pieceDescriptor;
456
+ private triggerDescriptor;
418
457
  private deliveryFor;
419
458
  private enable;
420
459
  private renewAtAfterEnable;
@@ -550,6 +589,12 @@ export declare class WorkflowRuntimeService {
550
589
  }): Promise<BlockResolution>;
551
590
  private logResolution;
552
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;
553
598
  private readonly unarmed;
554
599
  private reportUnarmedTrigger;
555
600
  private readonly resolutionRetries;
@@ -610,6 +655,14 @@ export declare class WorkflowRuntimeService {
610
655
  private pieceHandshakeConfig;
611
656
  private deliverToPiece;
612
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;
613
666
  private readonly descriptors;
614
667
  private designWorker?;
615
668
  private designEgress;
@@ -658,7 +711,7 @@ export declare class WorkflowRuntimeService {
658
711
  private assertCanReadDocument;
659
712
  private assertCanReadWorkflow;
660
713
  private assertCanWriteDocument;
661
- 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>;
662
715
  blockOutputTree(block: BlockRef, config?: unknown): Promise<OutputTree>;
663
716
  private stateFields;
664
717
  private operationInputFields;
@@ -681,8 +734,11 @@ export declare class WorkflowRuntimeService {
681
734
  rerunOf: string;
682
735
  }, ctx?: WorkflowCaller, enqueuedRunId?: string): Promise<PersistedRunResult>;
683
736
  rerun(runId: string, ctx?: WorkflowCaller): Promise<PersistedRunResult>;
737
+ private rereads;
684
738
  testStep(workflowId: string, stepId: string, ctx?: WorkflowCaller, access?: WorkflowAccessOptions): Promise<StepTestResult>;
685
739
  private testScope;
740
+ private readReferencedDocuments;
741
+ private documentShapes;
686
742
  private lastTestSample;
687
743
  stepOutputTree(workflowId: string, stepId: string, ctx?: WorkflowCaller): Promise<OutputTree>;
688
744
  blockResolutions(workflowId: string, ctx?: WorkflowCaller): Promise<BlockResolutionRecord[]>;
@@ -696,6 +752,9 @@ export declare class InvalidRunCursorError extends Error {
696
752
  constructor();
697
753
  }
698
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
699
758
  //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/operation-node/operation-node.d.ts
700
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';
701
760
  interface OperationNode {
@@ -19291,6 +19350,6 @@ interface WebhookPayload {
19291
19350
  body: unknown;
19292
19351
  }
19293
19352
  //#endregion
19294
- 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 };
19295
19354
  export {};
19296
19355
  //# sourceMappingURL=index.d.ts.map