@powerhousedao/reactor-workflow 6.2.3-dev.78 → 6.2.3-dev.80
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 +18 -1
- package/dist/index.d.ts +137 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +315 -28
- package/dist/index.js.map +1 -1
- package/dist/piece-registry-BbeuE8TB.d.ts.map +1 -1
- package/dist/{telemetry-CiXdMoVa.js → telemetry-BCXPCbfB.js} +3 -3
- package/dist/telemetry-BCXPCbfB.js.map +1 -0
- package/dist/testing.js +1 -1
- package/dist/worker-entry.js +26 -0
- package/dist/worker-entry.js.map +1 -1
- package/package.json +7 -7
- package/dist/telemetry-CiXdMoVa.js.map +0 -1
package/README.md
CHANGED
|
@@ -277,13 +277,21 @@ returns it when it settles: a step, a trigger hook, an editor's options or
|
|
|
277
277
|
describe. A run holds no child between steps. Trigger hooks have children of
|
|
278
278
|
their own, so a burst of runs can't delay a poll, and so does the editor (one
|
|
279
279
|
child, which exits when idle). A child is retired when it
|
|
280
|
-
dies or times out,
|
|
280
|
+
dies or times out, past 80% of
|
|
281
281
|
its heap budget, after `PH_WORKFLOWS_WORKER_MAX_REQUESTS` requests, or after a
|
|
282
282
|
minute idle above `PH_WORKFLOWS_WORKER_MIN`.
|
|
283
283
|
|
|
284
284
|
Piece code is trusted: what a piece keeps in module state carries over to the
|
|
285
285
|
next request its child serves, whichever workflow sent it.
|
|
286
286
|
|
|
287
|
+
Certificate checks stay on in every child (`worker/tls-guard.ts`). Pieces
|
|
288
|
+
bundled with an old pieces-common set `NODE_TLS_REJECT_UNAUTHORIZED=0` before
|
|
289
|
+
every request, which would switch verification off process-wide; the guard
|
|
290
|
+
gives every `tls.connect` an explicit `rejectUnauthorized: true` unless the
|
|
291
|
+
caller explicitly asks for `false`, so fetch, https and the HTTP clients
|
|
292
|
+
pieces bundle all verify. The worker still reports a request that set the
|
|
293
|
+
variable (`tlsPoisoned`), but no longer retires the child for it.
|
|
294
|
+
|
|
287
295
|
That entry is `src/worker/entry.ts`: the piece worker from `src/pieces`, plus
|
|
288
296
|
`ctx.reactor` (`src/worker/reactor.ts`), which needs `@powerhousedao/reactor`
|
|
289
297
|
and so lives outside the piece layer. For an action, trigger or option resolver
|
|
@@ -295,6 +303,15 @@ the request settles. The boot document models reach the child on fork as
|
|
|
295
303
|
up with a `model-entries` host call the first time a piece asks for it. Either
|
|
296
304
|
way the model is imported on first use.
|
|
297
305
|
|
|
306
|
+
`ctx.reactor.query` is served the same way, by the host's optional
|
|
307
|
+
`queryIndex` dep (`WorkflowRuntimeHostDeps`): a read of a read-model index the
|
|
308
|
+
host registers as a GraphQL subgraph, run in the host process as the run user,
|
|
309
|
+
so the index's own access rules decide as they do over HTTP. A host that hands
|
|
310
|
+
over no `queryIndex` refuses the method by name, and a run with no user is
|
|
311
|
+
refused under enforcement like every other read. Switchboard answers it from
|
|
312
|
+
the GraphQL manager (`executeSubgraph`), so a piece never needs the
|
|
313
|
+
switchboard's URL or a bearer of its own to read an index.
|
|
314
|
+
|
|
298
315
|
## Blocks
|
|
299
316
|
|
|
300
317
|
A step names its block the way Activepieces does, with three fields:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as StepExecutionRecord, F as BlockResolution, I as PieceOrigin, O as PieceResolver, P as BlockMatch, S as PropertySettingDef, T as ReactorTap, _ as PieceWorkerResult, b as WorkflowTelemetryOptions, f as SecretStore, h as ModelManifestSource, i as ReplayedStep, j as EgressPolicy, l as ConnectionRequest, m as IPieceWorker, n as packagePieces, r as CORE_PIECE_NAME, s as AttachmentPort, t as PieceRegistry, v as TELEMETRY_SCOPE, w as WorkflowRunResult, y as WorkflowTelemetry } from "./piece-registry-BbeuE8TB.js";
|
|
2
|
-
import { ActionBase, TriggerBase } from "@powerhousedao/pieces-framework";
|
|
2
|
+
import { ActionBase, IndexQueryRequest, IndexQueryResult, TriggerBase } from "@powerhousedao/pieces-framework";
|
|
3
3
|
import { ILogger, OperationWithContext } from "document-model";
|
|
4
4
|
import "@powerhousedao/pieces-framework/workflow";
|
|
5
5
|
import { BlockIdentity, BlockRef } from "@powerhousedao/pieces-framework/block-type";
|
|
@@ -46,6 +46,70 @@ export declare const WORKFLOW_PACKAGE_NAME = "@powerhousedao/workflow";
|
|
|
46
46
|
//#region src/pieces/activepieces/registry-source.d.ts
|
|
47
47
|
export declare function setPieceRegistryUrl(url: string | undefined): void;
|
|
48
48
|
//#endregion
|
|
49
|
+
//#region src/reactor/oauth-apps.d.ts
|
|
50
|
+
/** The connection config key naming an app of the registry. */
|
|
51
|
+
export declare const OAUTH_APP = "oauth_app";
|
|
52
|
+
/**
|
|
53
|
+
* The connection config key for the scopes to ask for instead of the piece's
|
|
54
|
+
* own: a list, or one space-separated string. A read-only integration asks
|
|
55
|
+
* for `calendar.readonly` where the piece would ask to edit too.
|
|
56
|
+
*/
|
|
57
|
+
export declare const OAUTH_SCOPES = "oauth_scopes";
|
|
58
|
+
type OAuthClientKind = "web" | "desktop";
|
|
59
|
+
interface OAuthAppClient {
|
|
60
|
+
appId: string;
|
|
61
|
+
kind: OAuthClientKind;
|
|
62
|
+
clientId: string;
|
|
63
|
+
clientSecretRef: string;
|
|
64
|
+
}
|
|
65
|
+
interface OAuthAppRegistry {
|
|
66
|
+
client(appId: string, kind: OAuthClientKind): OAuthAppClient | undefined;
|
|
67
|
+
clients(appId: string): OAuthAppClient[];
|
|
68
|
+
}
|
|
69
|
+
/** One app as a host configures it: per client kind, the provider's client file. */
|
|
70
|
+
interface OAuthAppDefinition {
|
|
71
|
+
id: string;
|
|
72
|
+
/** Paths to the provider's downloaded client files (Google's client_secret_*.json). */
|
|
73
|
+
clients: Partial<Record<OAuthClientKind, string>>;
|
|
74
|
+
}
|
|
75
|
+
export declare class StaticOAuthAppRegistry implements OAuthAppRegistry {
|
|
76
|
+
private readonly entries;
|
|
77
|
+
constructor(entries: readonly OAuthAppClient[]);
|
|
78
|
+
client(appId: string, kind: OAuthClientKind): OAuthAppClient | undefined;
|
|
79
|
+
clients(appId: string): OAuthAppClient[];
|
|
80
|
+
}
|
|
81
|
+
/** Desktop for a callback to this machine, web for one the provider reaches over the internet. */
|
|
82
|
+
export declare function clientKindFor(redirectUri: string): OAuthClientKind;
|
|
83
|
+
/**
|
|
84
|
+
* Config key the runtime writes after a sign-in: the scopes the provider
|
|
85
|
+
* granted (its token response's `scope`, else the ones asked for). A
|
|
86
|
+
* connection whose `oauth_scopes` reach beyond them needs a new sign-in.
|
|
87
|
+
*/
|
|
88
|
+
export declare const OAUTH_GRANTED_SCOPES = "oauth_granted_scopes";
|
|
89
|
+
/** What a sign-in was granted: the token's own `scope`, else what the connection asked for. */
|
|
90
|
+
export declare function grantedScopes(tokenScope: string | undefined, config: Record<string, unknown>): string[] | undefined;
|
|
91
|
+
/** The scopes a connection asks for instead of the piece's, or undefined to keep the piece's. */
|
|
92
|
+
export declare function scopesOverride(config: Record<string, unknown>): string[] | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* The client id and secret in a provider's client file: Google's
|
|
95
|
+
* `{ installed | web: { client_id, client_secret } }`, or the two keys at the
|
|
96
|
+
* top level.
|
|
97
|
+
*/
|
|
98
|
+
export declare function parseClientFile(text: string): {
|
|
99
|
+
clientId: string;
|
|
100
|
+
clientSecret: string;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Reads each configured client file and keeps its secret in the store under a
|
|
104
|
+
* fixed label: created the first time, rotated when the file changed, left
|
|
105
|
+
* alone otherwise. A client whose file cannot be read is skipped with the
|
|
106
|
+
* reason, so one bad file does not take the others down.
|
|
107
|
+
*/
|
|
108
|
+
export declare function loadOAuthApps(definitions: readonly OAuthAppDefinition[], store: SecretStore, options?: {
|
|
109
|
+
read?: (path: string) => Promise<string>;
|
|
110
|
+
onSkip?: (appId: string, kind: OAuthClientKind, reason: string) => void;
|
|
111
|
+
}): Promise<StaticOAuthAppRegistry>;
|
|
112
|
+
//#endregion
|
|
49
113
|
//#region src/reactor/run-scope.d.ts
|
|
50
114
|
interface ReactorConnectionScope {
|
|
51
115
|
access: "read" | "write";
|
|
@@ -86,12 +150,14 @@ interface WorkflowRuntimeHostDeps {
|
|
|
86
150
|
authEnforcement?: boolean;
|
|
87
151
|
hostPrincipal?: Principal;
|
|
88
152
|
hostIdentity?: HostIdentity;
|
|
153
|
+
queryIndex?(request: IndexQueryRequest, runUser: RunUser | null, signal?: AbortSignal): Promise<IndexQueryResult>;
|
|
89
154
|
modelManifest?(): ModelManifestEntry[];
|
|
90
155
|
modelEntries?(documentType: string): ModelManifestEntry[];
|
|
91
156
|
webhooks?: IWebhookScope;
|
|
92
157
|
attachments?: AttachmentClientLike;
|
|
93
158
|
canReadAttachmentRef?(request: AttachmentReadRequest): Promise<boolean>;
|
|
94
159
|
secrets?: SecretStore;
|
|
160
|
+
oauthApps?: readonly OAuthAppDefinition[];
|
|
95
161
|
secretsKeyFile?: string | false;
|
|
96
162
|
logger?: ILogger;
|
|
97
163
|
telemetry?: WorkflowTelemetryOptions;
|
|
@@ -19151,6 +19217,7 @@ interface TriggerSupervisorOptions {
|
|
|
19151
19217
|
parks?: ParkState;
|
|
19152
19218
|
resolveAuth: (connectionId: string | null | undefined, request?: ConnectionRequest) => Promise<unknown>;
|
|
19153
19219
|
fire: (workflowId: string, payload: unknown, kind: string, runId: string) => void;
|
|
19220
|
+
pollHeld?: (workflowId: string) => boolean;
|
|
19154
19221
|
cacheDir: string;
|
|
19155
19222
|
resolver?: PieceResolver;
|
|
19156
19223
|
worker?: IPieceWorker;
|
|
@@ -19203,6 +19270,13 @@ declare class TriggerSupervisor {
|
|
|
19203
19270
|
/** A disable clears the park. With no binding in memory to release a PARKED
|
|
19204
19271
|
* row through onDisable (a boot), the row is turned DISABLED here. */
|
|
19205
19272
|
releasePark(workflowId: string, flipRow: boolean): Promise<void>;
|
|
19273
|
+
/**
|
|
19274
|
+
* Makes an armed trigger due now and runs the due check at once, so a
|
|
19275
|
+
* schedule fires and a poll polls without waiting for its interval ("sync
|
|
19276
|
+
* now"). The next one follows the interval from there. False when the
|
|
19277
|
+
* workflow has no armed trigger (disabled, parked, erroring, unknown).
|
|
19278
|
+
*/
|
|
19279
|
+
pollNow(workflowId: string): Promise<boolean>;
|
|
19206
19280
|
/** A re-publish past the parked version: on this lane, a park older than
|
|
19207
19281
|
* `publishedVersion` goes and a row it parked is ENABLED again, as it was
|
|
19208
19282
|
* before (only an ENABLED row is ever parked); a park as new stands. The
|
|
@@ -19343,6 +19417,27 @@ interface WebhookEndpointRecord {
|
|
|
19343
19417
|
armed: boolean;
|
|
19344
19418
|
createdAt: string;
|
|
19345
19419
|
}
|
|
19420
|
+
/**
|
|
19421
|
+
* One workflow's trigger as the runtime holds it. `trigger` is null when the
|
|
19422
|
+
* runtime holds no trigger row (never armed, or a webhook/schedule kind);
|
|
19423
|
+
* `park` is set while a failed run keeps the trigger unarmed, until the
|
|
19424
|
+
* workflow is re-enabled or re-published.
|
|
19425
|
+
*/
|
|
19426
|
+
type WorkflowHealth = {
|
|
19427
|
+
trigger: {
|
|
19428
|
+
/** ENABLED | DISABLED | ERROR | PARKED */
|
|
19429
|
+
status: string;
|
|
19430
|
+
lastError: string | null;
|
|
19431
|
+
lastPollAt: string | null;
|
|
19432
|
+
nextPollAt: string | null;
|
|
19433
|
+
consecutiveFailures: number;
|
|
19434
|
+
} | null;
|
|
19435
|
+
park: {
|
|
19436
|
+
reason: string;
|
|
19437
|
+
parkedAt: string;
|
|
19438
|
+
publishedVersion: number;
|
|
19439
|
+
} | null;
|
|
19440
|
+
};
|
|
19346
19441
|
export declare class WorkflowRuntimeService {
|
|
19347
19442
|
private readonly host;
|
|
19348
19443
|
private readonly logger;
|
|
@@ -19363,6 +19458,7 @@ export declare class WorkflowRuntimeService {
|
|
|
19363
19458
|
private secretsPromise?;
|
|
19364
19459
|
private oauthAttemptsPromise?;
|
|
19365
19460
|
private tokenRefresher?;
|
|
19461
|
+
private oauthAppsPromise?;
|
|
19366
19462
|
private readonly registry;
|
|
19367
19463
|
private readonly seedPromise;
|
|
19368
19464
|
private seedError?;
|
|
@@ -19375,6 +19471,8 @@ export declare class WorkflowRuntimeService {
|
|
|
19375
19471
|
secrets(): Promise<SecretStore>;
|
|
19376
19472
|
private secretProvider;
|
|
19377
19473
|
private oauthAttempts;
|
|
19474
|
+
/** The host's OAuth2 apps, their client secrets loaded into the store once. */
|
|
19475
|
+
private oauthApps;
|
|
19378
19476
|
private oauthRefresher;
|
|
19379
19477
|
/** The seeding failure a restart is needed to clear, or undefined while the
|
|
19380
19478
|
* registry is seeded. Resolves once seeding has finished either way. */
|
|
@@ -19461,6 +19559,19 @@ export declare class WorkflowRuntimeService {
|
|
|
19461
19559
|
private closed;
|
|
19462
19560
|
private throwIfClosed;
|
|
19463
19561
|
shutdown(): void;
|
|
19562
|
+
/**
|
|
19563
|
+
* Runs a workflow's trigger now, as its schedule or poll would (a sync
|
|
19564
|
+
* now): a schedule fires the workflow, a polling trigger polls its source.
|
|
19565
|
+
* Never a backfill's pace. False when it has no armed trigger.
|
|
19566
|
+
*/
|
|
19567
|
+
pollNow(workflowId: string, ctx?: WorkflowCaller): Promise<boolean>;
|
|
19568
|
+
/**
|
|
19569
|
+
* How one workflow's trigger stands, for host-side code that keeps
|
|
19570
|
+
* workflows running (a processor reconciling the workflows it built): the
|
|
19571
|
+
* trigger row, and the park that holds it unarmed. Not caller-filtered:
|
|
19572
|
+
* GraphQL callers go through triggerStates.
|
|
19573
|
+
*/
|
|
19574
|
+
workflowHealth(workflowId: string): Promise<WorkflowHealth>;
|
|
19464
19575
|
triggerStates(ctx?: WorkflowCaller): Promise<TriggerStateRow[]>;
|
|
19465
19576
|
private webhookEndpoints?;
|
|
19466
19577
|
private webhookScope?;
|
|
@@ -19563,6 +19674,20 @@ export declare class WorkflowRuntimeService {
|
|
|
19563
19674
|
fire(workflowId: string, triggerPayload?: unknown, triggerKind?: string, resume?: RunResume, ctx?: WorkflowCaller, enqueuedRunId?: string): Promise<PersistedRunResult>;
|
|
19564
19675
|
private runFired;
|
|
19565
19676
|
private readonly runGate;
|
|
19677
|
+
private readonly unsettledFirings;
|
|
19678
|
+
private readonly runLimits;
|
|
19679
|
+
/**
|
|
19680
|
+
* Whether a due poll of this workflow's trigger should wait: its runs are
|
|
19681
|
+
* serialised (QUEUE, SINGLETON, a bounded PARALLEL) and every slot is taken
|
|
19682
|
+
* by a firing that has not settled. A polling trigger that hands out work
|
|
19683
|
+
* advances its own position when polled (the backfill's for-every moves its
|
|
19684
|
+
* cursor), so a poll now would only add a firing that waits in the queue,
|
|
19685
|
+
* where it can expire past `runTimeoutSeconds` or be skipped by a park,
|
|
19686
|
+
* with the position already gone. The supervisor leaves the poll due and
|
|
19687
|
+
* looks again on its next tick.
|
|
19688
|
+
*/
|
|
19689
|
+
private pollHeld;
|
|
19690
|
+
private settleFiring;
|
|
19566
19691
|
private readonly heldReplies;
|
|
19567
19692
|
/** Why a trigger's firing of a PARKED workflow is refused; undefined when
|
|
19568
19693
|
* it is not parked, or when an operator started the run. */
|
|
@@ -19749,9 +19874,18 @@ export declare function publishRunUser(client: Pick<IReactorClient, "getOperatio
|
|
|
19749
19874
|
//#region src/reactor/workflow-triggers-read-model.d.ts
|
|
19750
19875
|
export declare const WORKFLOW_TRIGGERS_READ_MODEL = "workflow-triggers";
|
|
19751
19876
|
export declare const WORKFLOW_TRIGGERS_READ_MODEL_STAGE: ReadModelRegistrationStage;
|
|
19752
|
-
|
|
19877
|
+
/**
|
|
19878
|
+
* What a processor on the runtime's host reads through
|
|
19879
|
+
* `getReadModel(WORKFLOW_TRIGGERS_READ_MODEL)`: whether a workflow's trigger
|
|
19880
|
+
* is armed, failing or parked. The model exists only where the runtime runs.
|
|
19881
|
+
*/
|
|
19882
|
+
interface WorkflowHealthReader {
|
|
19883
|
+
health(workflowId: string): Promise<WorkflowHealth>;
|
|
19884
|
+
}
|
|
19885
|
+
export declare class WorkflowTriggersReadModel extends BaseReadModel implements WorkflowHealthReader {
|
|
19753
19886
|
private readonly runtime;
|
|
19754
19887
|
constructor(db: Kysely<DocumentViewDatabase>, operationIndex: IOperationIndex, writeCache: IWriteCache, consistencyTracker: IConsistencyTracker, runtime: WorkflowRuntimeService);
|
|
19888
|
+
health(workflowId: string): Promise<WorkflowHealth>;
|
|
19755
19889
|
protected commitOperations(items: OperationWithContext[]): Promise<void>;
|
|
19756
19890
|
}
|
|
19757
19891
|
//#endregion
|
|
@@ -19782,6 +19916,6 @@ interface WebhookPayload {
|
|
|
19782
19916
|
body: unknown;
|
|
19783
19917
|
}
|
|
19784
19918
|
//#endregion
|
|
19785
|
-
export { type AcquireSingletonOptions, type AttachmentClientLike, type AttachmentReadRequest, 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, TELEMETRY_SCOPE, type TriggerBinding, type TriggerDedupeRow, type TriggerStateRow, type WebhookConfig, type WebhookPayload, type WorkflowAccessOptions, type WorkflowCaller, type WorkflowRuntimeDB, type WorkflowRuntimeHostDeps, type WorkflowSingletonLease, type WorkflowSingletonLoss, type WorkflowTelemetryOptions, packagePieces };
|
|
19919
|
+
export { type AcquireSingletonOptions, type AttachmentClientLike, type AttachmentReadRequest, type BlockResolutionRecord, CORE_PIECE_NAME, type ConnectionCheckResult, type ConnectionSummary, type HostIdentity, type OAuthAppClient, type OAuthAppDefinition, type OAuthAppRegistry, type OAuthAttemptStatus, type OAuthAttemptView, type OAuthClientKind, 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, TELEMETRY_SCOPE, type TriggerBinding, type TriggerDedupeRow, type TriggerStateRow, type WebhookConfig, type WebhookPayload, type WorkflowAccessOptions, type WorkflowCaller, type WorkflowHealth, type WorkflowHealthReader, type WorkflowRuntimeDB, type WorkflowRuntimeHostDeps, type WorkflowSingletonLease, type WorkflowSingletonLoss, type WorkflowTelemetryOptions, packagePieces };
|
|
19786
19920
|
export {};
|
|
19787
19921
|
//# sourceMappingURL=index.d.ts.map
|