@fluidgrids/workflows 2026.1028.2 → 2026.1030.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.
- package/README.md +181 -11
- package/dist/{activation-BBh1p82z.d.cts → activation-DqUfpHzk.d.cts} +1 -1
- package/dist/{activation-DnhG7SmF.d.ts → activation-xpx1oWuo.d.ts} +1 -1
- package/dist/{chunk-VRHHBPT6.js → chunk-2D3MYIIF.js} +1212 -128
- package/dist/chunk-3U2NU7YC.cjs +124 -0
- package/dist/{chunk-NEIUQASE.cjs → chunk-4QKB4ARC.cjs} +3 -3
- package/dist/{chunk-GBQ33SIZ.cjs → chunk-54FLQNUM.cjs} +12 -1
- package/dist/chunk-5HIVIV53.js +330 -0
- package/dist/chunk-5MFVJM76.js +1222 -0
- package/dist/{chunk-JD2VQIDZ.cjs → chunk-672KMMBK.cjs} +2 -2
- package/dist/{chunk-C5OLWZ42.js → chunk-6A2FGSUS.js} +22 -14
- package/dist/{chunk-XKJA7KX3.js → chunk-6OLN6BMB.js} +52 -3
- package/dist/{chunk-6FSHT5IL.js → chunk-7EZIANC7.js} +1 -1
- package/dist/{chunk-2J6TF7YI.cjs → chunk-A5SXCA62.cjs} +10 -3
- package/dist/{chunk-BO6OVILK.js → chunk-AC6ZEXVR.js} +10 -4
- package/dist/{chunk-ABFZWYHT.js → chunk-AE5Q6ZAJ.js} +315 -50
- package/dist/chunk-C4F5KJTI.js +293 -0
- package/dist/{chunk-IISBRUWJ.js → chunk-G5H32GIG.js} +1 -1
- package/dist/chunk-GEQDGUGB.cjs +2719 -0
- package/dist/{chunk-XHXIDVEC.js → chunk-HCM7ZC7Q.js} +1 -1
- package/dist/chunk-HMZUGSMU.cjs +1554 -0
- package/dist/{chunk-SAOBPYYJ.cjs → chunk-IQPXHQQQ.cjs} +8 -4
- package/dist/{chunk-P6TA5EZT.cjs → chunk-ISOIA7NV.cjs} +335 -58
- package/dist/chunk-JSC75O5C.cjs +167 -0
- package/dist/chunk-M272AHEX.js +25 -0
- package/dist/{chunk-BD7ZPG53.js → chunk-NWQ5WRLE.js} +10 -2
- package/dist/chunk-ODZ2IAR2.cjs +1247 -0
- package/dist/chunk-Q4MWQNJK.cjs +28 -0
- package/dist/{chunk-HWJZVOG7.js → chunk-SR7TR5KX.js} +6 -2
- package/dist/{chunk-FEW3JBYA.cjs → chunk-TCTE7DX5.cjs} +3 -3
- package/dist/{chunk-623FVQSN.cjs → chunk-TYF56RGB.cjs} +123 -0
- package/dist/chunk-VA4OFR72.cjs +324 -0
- package/dist/chunk-VU5S5A7V.js +150 -0
- package/dist/chunk-YEHR4NNE.js +1522 -0
- package/dist/{chunk-FMSW2HDF.cjs → chunk-ZCGKGDCL.cjs} +23 -15
- package/dist/codegen/index.d.cts +2 -2
- package/dist/codegen/index.d.ts +2 -2
- package/dist/collect-6NIEufHd.d.ts +103 -0
- package/dist/collect-CcTCKqx6.d.cts +103 -0
- package/dist/{file-BOoHZgoQ.d.cts → file-BxYpwjRQ.d.cts} +1007 -21
- package/dist/{file-yuPCFU5b.d.ts → file-CFdPQJI9.d.ts} +1007 -21
- package/dist/history/index.cjs +375 -86
- package/dist/history/index.d.cts +590 -12
- package/dist/history/index.d.ts +590 -12
- package/dist/history/index.js +50 -4
- package/dist/index.cjs +156 -50
- package/dist/index.d.cts +38 -58
- package/dist/index.d.ts +38 -58
- package/dist/index.js +6 -4
- package/dist/interceptors-CNcr2dlk.d.ts +159 -0
- package/dist/interceptors-CqkNZVfI.d.cts +159 -0
- package/dist/ir/index.cjs +362 -38
- package/dist/ir/index.d.cts +282 -7
- package/dist/ir/index.d.ts +282 -7
- package/dist/ir/index.js +329 -23
- package/dist/{lower-BzmUz0sq.d.cts → lower-BtRfIW2A.d.cts} +56 -8
- package/dist/{lower-_-iT4HYs.d.ts → lower-CpsMFOFX.d.ts} +56 -8
- package/dist/{manifest-C8N6HDYl.d.ts → manifest-D-I_twys.d.ts} +1 -1
- package/dist/{manifest-0OLw0i7k.d.cts → manifest-DahBQVM8.d.cts} +1 -1
- package/dist/node-evaluator-DGQDPSPI.cjs +24 -0
- package/dist/node-evaluator-LEEVD7H7.js +14 -0
- package/dist/payload-fields-BVRQn2yH.d.cts +122 -0
- package/dist/payload-fields-oOBWxDiG.d.ts +122 -0
- package/dist/quickjs/index.cjs +28 -27
- package/dist/quickjs/index.d.cts +6 -6
- package/dist/quickjs/index.d.ts +6 -6
- package/dist/quickjs/index.js +10 -9
- package/dist/roundtrip/index.cjs +259 -51
- package/dist/roundtrip/index.d.cts +100 -9
- package/dist/roundtrip/index.d.ts +100 -9
- package/dist/roundtrip/index.js +177 -11
- package/dist/runtime/index.cjs +21 -20
- package/dist/runtime/index.d.cts +184 -15
- package/dist/runtime/index.d.ts +184 -15
- package/dist/runtime/index.js +8 -7
- package/dist/testing/index.cjs +1122 -115
- package/dist/testing/index.d.cts +294 -13
- package/dist/testing/index.d.ts +294 -13
- package/dist/testing/index.js +1086 -84
- package/dist/{types-DV-HX_Gt.d.ts → types-Bv2i4cBX.d.cts} +244 -33
- package/dist/{types-CpBBjaGX.d.cts → types-DGx-b9eq.d.ts} +244 -33
- package/dist/{types-BGoPzgcl.d.ts → types-V7jEEUaL.d.cts} +20 -1
- package/dist/{types-BGoPzgcl.d.cts → types-V7jEEUaL.d.ts} +20 -1
- package/dist/{workflow-Bpr3vnA_.d.ts → workflow-B18OeF7g.d.ts} +2 -2
- package/dist/workflow-BGnv8SS6.d.ts +803 -0
- package/dist/{workflow-FXUkpIBc.d.cts → workflow-BJPFv3cp.d.cts} +2 -2
- package/dist/workflow-DS32Gtws.d.cts +803 -0
- package/fixtures/histories/activity-options-updated.history.json +159 -0
- package/fixtures/histories/activity-paused-unpaused.history.json +160 -0
- package/fixtures/histories/auto-upgrade-patched.history.json +276 -0
- package/fixtures/histories/benign-failure.history.json +146 -0
- package/fixtures/histories/cancel-activity-try-cancel.history.json +150 -0
- package/fixtures/histories/child-cancel-wait-requested.history.json +217 -0
- package/fixtures/histories/child-options-roundtrip.history.json +192 -0
- package/fixtures/histories/codec-opaque.history.json +229 -0
- package/fixtures/histories/continue-as-new-last-result.history.json +86 -0
- package/fixtures/histories/continue-as-new-options.history.json +99 -0
- package/fixtures/histories/continue-as-new-r1-long-task-queue.history.json +78 -0
- package/fixtures/histories/continue-as-new-r1-retry-options.history.json +83 -0
- package/fixtures/histories/dynamic-workflow.history.json +150 -0
- package/fixtures/histories/execution-timeout-chain.history.json +98 -0
- package/fixtures/histories/external-cancel-resolved.history.json +123 -0
- package/fixtures/histories/external-cancel-unknown-target.history.json +127 -0
- package/fixtures/histories/failure-error-types-fails-run.history.json +144 -0
- package/fixtures/histories/handler-drain-warn.history.json +222 -0
- package/fixtures/histories/heartbeat-details-on-retry.history.json +145 -0
- package/fixtures/histories/interceptor-headers.history.json +339 -0
- package/fixtures/histories/local-activity-abandoned-at-completion.history.json +73 -0
- package/fixtures/histories/local-activity-cancelled-in-scope.history.json +118 -0
- package/fixtures/histories/local-activity-completed.history.json +157 -0
- package/fixtures/histories/local-activity-failed.history.json +93 -0
- package/fixtures/histories/local-activity-retry-in-task.history.json +88 -0
- package/fixtures/histories/query-custom.history.json +213 -0
- package/fixtures/histories/query-default-handler.history.json +120 -0
- package/fixtures/histories/reset-forked-reapplied-signals.history.json +239 -0
- package/fixtures/histories/reset-reapplied-update-admitted.history.json +228 -0
- package/fixtures/histories/run-retry-last-failure.history.json +90 -0
- package/fixtures/histories/run-timeout.history.json +159 -0
- package/fixtures/histories/schedule-to-start-timeout.history.json +132 -0
- package/fixtures/histories/search-attributes-upserted.history.json +177 -0
- package/fixtures/histories/start-delay-signal-ends-delay.history.json +155 -0
- package/fixtures/histories/typeerror-task-retry-100.history.json +137 -0
- package/fixtures/histories/update-accepted-completed.history.json +45 -30
- package/fixtures/histories/update-default-handler.history.json +246 -0
- package/fixtures/histories/update-handler-awaits-activity.history.json +196 -0
- package/fixtures/histories/update-not-handled.history.json +138 -0
- package/fixtures/histories/update-rejected-no-event.history.json +190 -0
- package/fixtures/histories/update-with-start-admitted.history.json +150 -0
- package/fixtures/histories/user-activity-cancel.history.json +149 -0
- package/fixtures/histories/user-activity-retry.history.json +143 -0
- package/fixtures/histories/user-activity.history.json +149 -0
- package/package.json +1 -1
- package/schema/bridge-v2.schema.json +1062 -0
- package/schema/history-file.schema.json +538 -83
- package/schema/ir-v2.schema.json +290 -0
- package/schema/payload-fields.json +162 -0
- package/schema/run-event.schema.json +503 -82
- package/schema/workflow-command.schema.json +372 -69
- package/schema/workflow-task.schema.json +924 -171
- package/dist/assemble-BLqQ8lSu.d.cts +0 -39
- package/dist/assemble-DWgaXHd-.d.ts +0 -39
- package/dist/chunk-DHTLALBL.cjs +0 -80
- package/dist/chunk-DJYMDLV5.js +0 -227
- package/dist/chunk-I5LR3D2K.js +0 -869
- package/dist/chunk-M4BBAERY.cjs +0 -1635
- package/dist/chunk-N23SKIG4.js +0 -73
- package/dist/chunk-PZCVF76Q.cjs +0 -868
- package/dist/chunk-QQ6ULXHI.cjs +0 -885
- package/dist/chunk-UK3WM7YZ.cjs +0 -75
- package/dist/chunk-VOKMAAJP.js +0 -848
- package/dist/node-evaluator-4MSDKWOG.cjs +0 -22
- package/dist/node-evaluator-SX4LEYQC.js +0 -12
- package/dist/workflow-C2a05WUJ.d.ts +0 -444
- package/dist/workflow-J-yYixny.d.cts +0 -444
package/dist/history/index.d.cts
CHANGED
|
@@ -1,9 +1,520 @@
|
|
|
1
|
-
import { W as WorkflowCommand, a as WorkflowTaskFailureCause, R as RetryPolicy,
|
|
2
|
-
export { A as ACTIVITY_CANCELLATION_TYPES,
|
|
3
|
-
import { H as HistoryIssue } from '../file-
|
|
4
|
-
export { A as ActivityState,
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { W as WorkflowCommand, T as TaskLogLine, Q as QueryResult, U as UnfinishedHandler, a as WorkflowTaskFailureCause, F as Failure, b as WorkflowInfoSnapshot, c as UpdateRequest, d as QueryRequest, R as RunEventRecord, e as RetryPolicy, f as RunRetryPolicy, C as ChildCancellationType, P as ParentClosePolicy } from '../types-Bv2i4cBX.cjs';
|
|
2
|
+
export { A as ACTIVITY_CANCELLATION_TYPES, g as ACTIVITY_NAME_PATTERN, h as AcceptUpdateCommand, i as ActivityCancellationType, B as BUILT_IN_QUERIES, j as BuiltInQueryName, k as CHILD_CANCELLATION_TYPES, l as COMMAND_EVENTS, m as COMMAND_EVENT_TYPES, n as COMMAND_TYPES, o as CONTINUE_AS_NEW_SUGGESTED_RATIO, p as CancelTimerCommand, q as CancelWorkflowCommand, r as ChildRunOptions, s as CommandType, t as CompleteUpdateCommand, u as CompleteWorkflowCommand, v as ContinueAsNewCommand, D as DEFAULT_HISTORY_LIMIT, E as ERROR_TYPES, w as EVENT_TYPES, x as EXECUTION_KINDS, y as ExecutionKind, z as FAIRNESS_KEY_MAX_LENGTH, G as FAIRNESS_WEIGHT_MAX, H as FAIRNESS_WEIGHT_MIN, I as FailWorkflowCommand, J as FailureSource, K as HISTORY_LIMIT_EXCEEDED_RATIO, L as HISTORY_PROTOCOL, M as Headers, N as HistoryLimit, O as INPUT_EVENTS, S as LOCAL_ACTIVITY_MAX_TIMEOUT_MS, V as LocalActivityRequest, X as LocalActivityResult, Y as MAX_ACTIVITY_CONNECTIONS, Z as MAX_HEADERS_BYTES, _ as MAX_SINK_CALLS, $ as PARENT_CLOSE_POLICIES, a0 as PHASE_B_CORE_COMMANDS, a1 as PHASE_B_PARITY_COMMANDS, a2 as PHASE_C_COMMANDS, a3 as RUNTIME_CAPABILITIES, a4 as RUNTIME_RELEASE, a5 as RecordLocalActivityCommand, a6 as RecordMarkerCommand, a7 as RecordSideEffectCommand, a8 as RejectUpdateCommand, a9 as RequestCancelActivityCommand, aa as RequestCancelExternalRunCommand, ab as RunEventDraft, ac as RunEventType, ad as RunTarget, ae as RuntimeCapability, af as ScheduleActivityCommand, ag as ScheduleNodeActivityCommand, ah as ScheduleUserActivityCommand, ai as SignalRunCommand, aj as SinkCall, ak as StartChildRunCommand, al as StartTimerCommand, am as TASK_FAILURE_CAUSES, an as TASK_QUEUE_NAME_PATTERN, ao as TERMINAL_COMMANDS, ap as TERMINAL_EVENTS, aq as UpsertContextCommand, ar as UpsertSearchAttributesCommand, as as VERSIONING_BEHAVIORS, at as VersioningBehavior, au as WORKFLOW_ID_CONFLICT_POLICIES, av as WORKFLOW_ID_REUSE_POLICIES, aw as WORKFLOW_TIMEOUT_TYPES, ax as WorkflowIdConflictPolicy, ay as WorkflowIdReusePolicy, az as WorkflowTaskRequest, aA as WorkflowTaskResult, aB as WorkflowTimeoutType, aC as WorkflowTimeouts, aD as isCommandEvent, aE as isInputEvent } from '../types-Bv2i4cBX.cjs';
|
|
3
|
+
import { H as HistoryIssue, C as CommandGate, a as CommandRelief } from '../file-BxYpwjRQ.cjs';
|
|
4
|
+
export { A as ActivityState, b as ActivityStatus, c as CODE_FEATURE_FLAGS, d as COMMAND_FEATURES, e as CORE_CAN_OPTIONS, f as CORE_CHILD_OPTIONS, g as ChildState, h as ChildStatus, i as CommandFeature, E as EventsForCommandsContext, j as EventsForCommandsResult, k as ExternalState, l as HISTORY_FILE_FORMAT, m as HISTORY_FILE_SCHEMA, n as HISTORY_FILE_SCHEMA_ID, o as HISTORY_SCHEMA_FILES, p as HistoryFile, q as HistoryFileError, r as HistoryStateError, L as LocalActivityState, P as PHASE_B_CORE_FEATURES, s as PHASE_B_PARITY_FEATURES, t as PHASE_C_CODE_FEATURES, u as PHASE_C_FEATURES, v as PHASE_C_FEATURE_FLAGS, R as RUN_EVENT_SCHEMA, w as RUN_EVENT_SCHEMA_ID, x as RunState, y as RunStatus, T as TimerState, U as UpdateState, W as WORKFLOW_COMMAND_SCHEMA, z as WORKFLOW_COMMAND_SCHEMA_ID, B as WORKFLOW_TASK_SCHEMA, D as WORKFLOW_TASK_SCHEMA_ID, F as applyEvent, G as codeFeaturesEnabledBy, I as commandFeatures, J as continueAsNewRetryShape, K as createHistoryFile, M as eventsForCommands, N as hasUnprocessedInput, O as initialRunState, Q as isActivityOpen, S as isChildOpen, V as isCommandEnabled, X as isReliefCommand, Y as isWorkflowCommandEnabled, Z as mergeSearchAttributes, _ as parseHistoryFile, $ as pendingCounts, a0 as projectRunState, a1 as serializeHistoryFile, a2 as taskCompletedEvents, a3 as unsupportedMessage, a4 as utf8Bytes } from '../file-BxYpwjRQ.cjs';
|
|
5
|
+
import { J as JsonObject, a as Json } from '../types-V7jEEUaL.cjs';
|
|
6
|
+
export { C as COMMAND_FAILURE_FIELDS, a as COMMAND_PAYLOAD_FIELDS, E as ENCODED_PAYLOAD_MARKER, b as ENCODED_PAYLOAD_VERSION, c as EncodedPayload, F as FAILURE_CAUSE_FIELD, d as FAILURE_FIELDS, e as FAILURE_PAYLOAD_FIELDS, K as KnownPayloadEncoding, P as PAYLOAD_ENCODINGS, f as PAYLOAD_FIELDS, g as PAYLOAD_FIELDS_DOCUMENT, h as PAYLOAD_FIELDS_FORMAT, i as isEncodedPayload, m as mapCommandPayloads, j as mapEventPayloads, k as mapPayloadFields, p as payloadEncodingOf } from '../payload-fields-BVRQn2yH.cjs';
|
|
7
|
+
export { A as Activation, s as splitActivations, u as unseenInputs } from '../activation-DqUfpHzk.cjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The worker bridge, protocol 2 (C-BRIDGE v2, PLAN-C §3.4): the frames a
|
|
11
|
+
* self-hosted worker and wspace-sandbox-svc exchange over `/runner-bridge`.
|
|
12
|
+
*
|
|
13
|
+
* sandbox-svc `src/modules/sandbox/workers/workerProtocol.ts` is the canonical
|
|
14
|
+
* copy; this one (and the Python SDK's `fluidgrids_workflows/worker/protocol.py`)
|
|
15
|
+
* mirrors it, and all three are tested against `schema/bridge-v2.schema.json`,
|
|
16
|
+
* generated from {@link BRIDGE_V2_SCHEMA}. Change the shapes only additively
|
|
17
|
+
* and in all three places.
|
|
18
|
+
*
|
|
19
|
+
* Transport (unchanged from v1): an outbound WebSocket to `/runner-bridge`
|
|
20
|
+
* with `Authorization: Bearer fgr_…`, JSON text frames, a ping every 20 s, a
|
|
21
|
+
* 65 s idle timeout and a 10 MiB frame cap. A `hello` with `protocol: 2` and
|
|
22
|
+
* `kind: 'worker'` selects v2 and needs a token of kind WORKER (otherwise the
|
|
23
|
+
* socket closes with {@link BridgeCloseCode.ProtocolError}).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** The protocol a `hello` names to select the worker bridge. */
|
|
27
|
+
declare const BRIDGE_PROTOCOL_VERSION = 2;
|
|
28
|
+
/** Path of the bridge WebSocket on sandbox-svc and on the public workspace gateway. */
|
|
29
|
+
declare const BRIDGE_PATH = "/runner-bridge";
|
|
30
|
+
/** How often a worker sends `ping`. */
|
|
31
|
+
declare const BRIDGE_PING_SECONDS = 20;
|
|
32
|
+
/** How often a worker sends `workerHeartbeat`. */
|
|
33
|
+
declare const BRIDGE_WORKER_HEARTBEAT_SECONDS = 30;
|
|
34
|
+
/** No frame for this long and the connection is treated as dead. */
|
|
35
|
+
declare const BRIDGE_IDLE_TIMEOUT_MS = 65000;
|
|
36
|
+
/** The largest frame. */
|
|
37
|
+
declare const BRIDGE_MAX_FRAME_BYTES: number;
|
|
38
|
+
/** The largest history tail a workflow `task` frame carries; the rest is paged with `history.page`. */
|
|
39
|
+
declare const BRIDGE_MAX_HISTORY_TAIL_BYTES: number;
|
|
40
|
+
/** WebSocket close codes (4000-4999 are application-defined); 4001-4009 are v1's. */
|
|
41
|
+
declare const BridgeCloseCode: {
|
|
42
|
+
readonly Unauthorized: 4001;
|
|
43
|
+
readonly Revoked: 4002;
|
|
44
|
+
readonly Replaced: 4003;
|
|
45
|
+
/** Also a v2 hello on a RUNNER token, or a v1 hello on a WORKER token. */
|
|
46
|
+
readonly ProtocolError: 4004;
|
|
47
|
+
readonly IdleTimeout: 4008;
|
|
48
|
+
/** The service is shutting down, or `WORKER_BRIDGE_ENABLED` is off. */
|
|
49
|
+
readonly ShuttingDown: 4009;
|
|
50
|
+
/** The workspace has no free worker seat (`fluidgrids.workers.count`). */
|
|
51
|
+
readonly QuotaExceeded: 4010;
|
|
52
|
+
/** The token does not allow a task queue the hello names. */
|
|
53
|
+
readonly QueueNotAllowed: 4011;
|
|
54
|
+
/** `fluidgrids.self-hosted-workers` (or a prerequisite) is off for the workspace. */
|
|
55
|
+
readonly FeatureDisabled: 4012;
|
|
56
|
+
};
|
|
57
|
+
type BridgeCloseCodeValue = (typeof BridgeCloseCode)[keyof typeof BridgeCloseCode];
|
|
58
|
+
/** Methods of a worker `req` frame. */
|
|
59
|
+
declare const BRIDGE_REQUEST_METHODS: readonly ["history.page", "activity.connection"];
|
|
60
|
+
type BridgeRequestMethod = (typeof BRIDGE_REQUEST_METHODS)[number];
|
|
61
|
+
/** Slots of one kind: in use and in total. */
|
|
62
|
+
interface BridgeSlotUsage {
|
|
63
|
+
used: number;
|
|
64
|
+
total: number;
|
|
65
|
+
}
|
|
66
|
+
/** A workflow task: one run's workflow task attempt. */
|
|
67
|
+
interface WorkflowTaskRef {
|
|
68
|
+
kind: 'workflow';
|
|
69
|
+
runId: string;
|
|
70
|
+
taskId: string;
|
|
71
|
+
attempt: number;
|
|
72
|
+
expectedHistoryLength: number;
|
|
73
|
+
}
|
|
74
|
+
/** A query task of a `determinism: worker` run (CX8). */
|
|
75
|
+
interface QueryTaskRef {
|
|
76
|
+
kind: 'query';
|
|
77
|
+
runId: string;
|
|
78
|
+
queryTaskId: string;
|
|
79
|
+
}
|
|
80
|
+
/** One attempt of an activity. */
|
|
81
|
+
interface ActivityTaskRef {
|
|
82
|
+
kind: 'activity';
|
|
83
|
+
runId: string;
|
|
84
|
+
activityId: string;
|
|
85
|
+
attempt: number;
|
|
86
|
+
}
|
|
87
|
+
type BridgeTaskRef = WorkflowTaskRef | QueryTaskRef | ActivityTaskRef;
|
|
88
|
+
/** A slice of a run's history, oldest first. */
|
|
89
|
+
interface BridgeHistoryPage {
|
|
90
|
+
events: RunEventRecord[];
|
|
91
|
+
/** Seq of the first event in `events` (1 for a full history). */
|
|
92
|
+
from: number;
|
|
93
|
+
/** The seq to page after for the next slice, or null at the end. */
|
|
94
|
+
nextAfter: number | null;
|
|
95
|
+
hasMore: boolean;
|
|
96
|
+
}
|
|
97
|
+
interface WorkerHelloFrame {
|
|
98
|
+
type: 'hello';
|
|
99
|
+
protocol: 2;
|
|
100
|
+
kind: 'worker';
|
|
101
|
+
sdk: {
|
|
102
|
+
language: 'typescript' | 'python';
|
|
103
|
+
version: string;
|
|
104
|
+
};
|
|
105
|
+
/** Default `hostname@pid`. */
|
|
106
|
+
identity: string;
|
|
107
|
+
taskQueues: string[];
|
|
108
|
+
/** Build ids of the workflow bundles the worker can run. */
|
|
109
|
+
buildIds: string[];
|
|
110
|
+
/** Workflow function names it registered (`*` for a dynamic workflow). */
|
|
111
|
+
workflows: string[];
|
|
112
|
+
/** Activity names it implements (`*` for a dynamic activity). */
|
|
113
|
+
activities: string[];
|
|
114
|
+
slots: {
|
|
115
|
+
workflow: number;
|
|
116
|
+
activity: number;
|
|
117
|
+
localActivity: number;
|
|
118
|
+
};
|
|
119
|
+
host: {
|
|
120
|
+
os?: string;
|
|
121
|
+
arch?: string;
|
|
122
|
+
hostname?: string;
|
|
123
|
+
runtime?: string;
|
|
124
|
+
};
|
|
125
|
+
/** Payload encodings its codec and converters produce and read. */
|
|
126
|
+
encodings: string[];
|
|
127
|
+
}
|
|
128
|
+
interface WorkerPingFrame {
|
|
129
|
+
type: 'ping';
|
|
130
|
+
t?: number;
|
|
131
|
+
}
|
|
132
|
+
/** How many task requests the worker keeps open, per kind. */
|
|
133
|
+
interface WorkerPollersFrame {
|
|
134
|
+
type: 'pollers';
|
|
135
|
+
workflow: number;
|
|
136
|
+
activity: number;
|
|
137
|
+
}
|
|
138
|
+
interface WorkflowTaskResultFrame {
|
|
139
|
+
type: 'taskResult';
|
|
140
|
+
taskRef: WorkflowTaskRef;
|
|
141
|
+
commands: WorkflowCommand[];
|
|
142
|
+
logs: TaskLogLine[];
|
|
143
|
+
/** The history length the worker's sticky cache holds for the run after this task. */
|
|
144
|
+
cachedUpTo: number;
|
|
145
|
+
queryResults?: QueryResult[];
|
|
146
|
+
unfinishedHandlers?: UnfinishedHandler[];
|
|
147
|
+
}
|
|
148
|
+
interface ActivityTaskResultFrame {
|
|
149
|
+
type: 'taskResult';
|
|
150
|
+
taskRef: ActivityTaskRef;
|
|
151
|
+
result: Json;
|
|
152
|
+
}
|
|
153
|
+
interface QueryTaskResultFrame {
|
|
154
|
+
type: 'taskResult';
|
|
155
|
+
taskRef: QueryTaskRef;
|
|
156
|
+
queryResults: QueryResult[];
|
|
157
|
+
}
|
|
158
|
+
type TaskResultFrame = WorkflowTaskResultFrame | ActivityTaskResultFrame | QueryTaskResultFrame;
|
|
159
|
+
/** Why a workflow task failed (the task result's failure). */
|
|
160
|
+
interface WorkflowTaskFailure {
|
|
161
|
+
cause: WorkflowTaskFailureCause;
|
|
162
|
+
message: string;
|
|
163
|
+
stackTrace?: string;
|
|
164
|
+
seq?: number;
|
|
165
|
+
errorType?: string;
|
|
166
|
+
}
|
|
167
|
+
type TaskFailedFrame = {
|
|
168
|
+
type: 'taskFailed';
|
|
169
|
+
taskRef: WorkflowTaskRef | QueryTaskRef;
|
|
170
|
+
failure: WorkflowTaskFailure;
|
|
171
|
+
} | {
|
|
172
|
+
type: 'taskFailed';
|
|
173
|
+
taskRef: ActivityTaskRef;
|
|
174
|
+
failure: Failure;
|
|
175
|
+
};
|
|
176
|
+
interface WorkerActivityHeartbeatFrame {
|
|
177
|
+
type: 'heartbeat';
|
|
178
|
+
reqId: string;
|
|
179
|
+
taskRef: ActivityTaskRef;
|
|
180
|
+
details?: Json;
|
|
181
|
+
}
|
|
182
|
+
interface WorkerHeartbeatFrame {
|
|
183
|
+
type: 'workerHeartbeat';
|
|
184
|
+
slots: {
|
|
185
|
+
workflow: BridgeSlotUsage;
|
|
186
|
+
activity: BridgeSlotUsage;
|
|
187
|
+
localActivity: BridgeSlotUsage;
|
|
188
|
+
};
|
|
189
|
+
pollers: {
|
|
190
|
+
workflow: number;
|
|
191
|
+
activity: number;
|
|
192
|
+
};
|
|
193
|
+
tasksInFlight: number;
|
|
194
|
+
cachedRuns: number;
|
|
195
|
+
}
|
|
196
|
+
interface WorkerRequestFrame {
|
|
197
|
+
type: 'req';
|
|
198
|
+
id: string;
|
|
199
|
+
method: BridgeRequestMethod;
|
|
200
|
+
params: JsonObject;
|
|
201
|
+
}
|
|
202
|
+
interface WorkerByeFrame {
|
|
203
|
+
type: 'bye';
|
|
204
|
+
reason: string;
|
|
205
|
+
}
|
|
206
|
+
type WorkerFrame = WorkerHelloFrame | WorkerPingFrame | WorkerPollersFrame | TaskResultFrame | TaskFailedFrame | WorkerActivityHeartbeatFrame | WorkerHeartbeatFrame | WorkerRequestFrame | WorkerByeFrame;
|
|
207
|
+
interface BridgeWelcomeFrame {
|
|
208
|
+
type: 'welcome';
|
|
209
|
+
protocol: 2;
|
|
210
|
+
sessionId: string;
|
|
211
|
+
/** `worker:<sessionId>`. */
|
|
212
|
+
workerId: string;
|
|
213
|
+
workspaceId: string;
|
|
214
|
+
heartbeatSeconds: number;
|
|
215
|
+
workerHeartbeatSeconds: number;
|
|
216
|
+
maxFrameBytes: number;
|
|
217
|
+
}
|
|
218
|
+
interface WorkflowTaskFrame {
|
|
219
|
+
type: 'task';
|
|
220
|
+
taskRef: WorkflowTaskRef;
|
|
221
|
+
/** The workflow task lease (`WorkflowTaskLease`), JSON. */
|
|
222
|
+
lease: JsonObject;
|
|
223
|
+
request: {
|
|
224
|
+
workflowFn: string;
|
|
225
|
+
info: WorkflowInfoSnapshot;
|
|
226
|
+
nowMs: number;
|
|
227
|
+
updates?: UpdateRequest[];
|
|
228
|
+
queries?: QueryRequest[];
|
|
229
|
+
};
|
|
230
|
+
history: BridgeHistoryPage;
|
|
231
|
+
}
|
|
232
|
+
interface QueryTaskFrame {
|
|
233
|
+
type: 'task';
|
|
234
|
+
taskRef: QueryTaskRef;
|
|
235
|
+
request: {
|
|
236
|
+
workflowFn: string;
|
|
237
|
+
info: WorkflowInfoSnapshot;
|
|
238
|
+
queries: QueryRequest[];
|
|
239
|
+
};
|
|
240
|
+
history: BridgeHistoryPage;
|
|
241
|
+
}
|
|
242
|
+
interface ActivityTaskFrame {
|
|
243
|
+
type: 'task';
|
|
244
|
+
taskRef: ActivityTaskRef;
|
|
245
|
+
/** The activity lease (`WorkflowActivityLease`), JSON. */
|
|
246
|
+
lease: JsonObject;
|
|
247
|
+
}
|
|
248
|
+
type BridgeTaskFrame = WorkflowTaskFrame | QueryTaskFrame | ActivityTaskFrame;
|
|
249
|
+
interface BridgeHeartbeatAckFrame {
|
|
250
|
+
type: 'heartbeatAck';
|
|
251
|
+
reqId: string;
|
|
252
|
+
cancelRequested: boolean;
|
|
253
|
+
paused: boolean;
|
|
254
|
+
pauseReason?: string;
|
|
255
|
+
}
|
|
256
|
+
interface BridgeCancelFrame {
|
|
257
|
+
type: 'cancel';
|
|
258
|
+
taskRef: BridgeTaskRef;
|
|
259
|
+
reason: string;
|
|
260
|
+
}
|
|
261
|
+
interface BridgeResponseFrame {
|
|
262
|
+
type: 'res';
|
|
263
|
+
id: string;
|
|
264
|
+
ok: boolean;
|
|
265
|
+
result?: Json;
|
|
266
|
+
error?: {
|
|
267
|
+
code: string;
|
|
268
|
+
message: string;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
interface BridgePongFrame {
|
|
272
|
+
type: 'pong';
|
|
273
|
+
t?: number;
|
|
274
|
+
}
|
|
275
|
+
type ServiceFrame = BridgeWelcomeFrame | BridgeTaskFrame | BridgeHeartbeatAckFrame | BridgeCancelFrame | BridgeResponseFrame | BridgePongFrame;
|
|
276
|
+
type BridgeFrame = WorkerFrame | ServiceFrame;
|
|
277
|
+
/**
|
|
278
|
+
* The JSON Schema of every bridge v2 frame (draft 2020-12). Commands, events,
|
|
279
|
+
* failures, the task info and query results are kept open here (`object`);
|
|
280
|
+
* their own schemas (`workflow-command`, `run-event`, `workflow-task`) check
|
|
281
|
+
* them.
|
|
282
|
+
*/
|
|
283
|
+
declare const BRIDGE_V2_SCHEMA_ID = "https://docs.fluidgrids.ai/schemas/bridge-v2.schema.json";
|
|
284
|
+
declare const BRIDGE_V2_SCHEMA: {
|
|
285
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
286
|
+
readonly $id: "https://docs.fluidgrids.ai/schemas/bridge-v2.schema.json";
|
|
287
|
+
readonly title: "FluidGrids worker bridge, protocol 2";
|
|
288
|
+
readonly description: "Frames between a self-hosted worker and wspace-sandbox-svc over /runner-bridge (JSON text frames, Bearer fgr_ token of kind WORKER, ping every 20 s, 65 s idle timeout, 10 MiB frame cap). Close codes: 4001 Unauthorized, 4002 Revoked, 4003 Replaced, 4004 ProtocolError, 4008 IdleTimeout, 4009 ShuttingDown, 4010 QuotaExceeded, 4011 QueueNotAllowed, 4012 FeatureDisabled.";
|
|
289
|
+
readonly oneOf: readonly [{
|
|
290
|
+
readonly $ref: "#/$defs/workerFrame";
|
|
291
|
+
}, {
|
|
292
|
+
readonly $ref: "#/$defs/serviceFrame";
|
|
293
|
+
}];
|
|
294
|
+
readonly $defs: {
|
|
295
|
+
readonly workflowTaskRef: {
|
|
296
|
+
readonly type: "object";
|
|
297
|
+
readonly required: readonly ["kind", "runId", "taskId", "attempt", "expectedHistoryLength"];
|
|
298
|
+
readonly properties: {
|
|
299
|
+
readonly kind: {
|
|
300
|
+
readonly const: "workflow";
|
|
301
|
+
};
|
|
302
|
+
readonly runId: {
|
|
303
|
+
readonly type: "string";
|
|
304
|
+
readonly minLength: 1;
|
|
305
|
+
readonly maxLength: 256;
|
|
306
|
+
};
|
|
307
|
+
readonly taskId: {
|
|
308
|
+
readonly type: "string";
|
|
309
|
+
readonly minLength: 1;
|
|
310
|
+
readonly maxLength: 256;
|
|
311
|
+
};
|
|
312
|
+
readonly attempt: {
|
|
313
|
+
readonly type: "integer";
|
|
314
|
+
readonly minimum: 1;
|
|
315
|
+
};
|
|
316
|
+
readonly expectedHistoryLength: {
|
|
317
|
+
readonly type: "integer";
|
|
318
|
+
readonly minimum: 1;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
readonly additionalProperties: false;
|
|
322
|
+
};
|
|
323
|
+
readonly queryTaskRef: {
|
|
324
|
+
readonly type: "object";
|
|
325
|
+
readonly required: readonly ["kind", "runId", "queryTaskId"];
|
|
326
|
+
readonly properties: {
|
|
327
|
+
readonly kind: {
|
|
328
|
+
readonly const: "query";
|
|
329
|
+
};
|
|
330
|
+
readonly runId: {
|
|
331
|
+
readonly type: "string";
|
|
332
|
+
readonly minLength: 1;
|
|
333
|
+
readonly maxLength: 256;
|
|
334
|
+
};
|
|
335
|
+
readonly queryTaskId: {
|
|
336
|
+
readonly type: "string";
|
|
337
|
+
readonly minLength: 1;
|
|
338
|
+
readonly maxLength: 256;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
readonly additionalProperties: false;
|
|
342
|
+
};
|
|
343
|
+
readonly activityTaskRef: {
|
|
344
|
+
readonly type: "object";
|
|
345
|
+
readonly required: readonly ["kind", "runId", "activityId", "attempt"];
|
|
346
|
+
readonly properties: {
|
|
347
|
+
readonly kind: {
|
|
348
|
+
readonly const: "activity";
|
|
349
|
+
};
|
|
350
|
+
readonly runId: {
|
|
351
|
+
readonly type: "string";
|
|
352
|
+
readonly minLength: 1;
|
|
353
|
+
readonly maxLength: 256;
|
|
354
|
+
};
|
|
355
|
+
readonly activityId: {
|
|
356
|
+
readonly type: "string";
|
|
357
|
+
readonly minLength: 1;
|
|
358
|
+
readonly maxLength: 256;
|
|
359
|
+
};
|
|
360
|
+
readonly attempt: {
|
|
361
|
+
readonly type: "integer";
|
|
362
|
+
readonly minimum: 1;
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
readonly additionalProperties: false;
|
|
366
|
+
};
|
|
367
|
+
readonly taskRef: {
|
|
368
|
+
readonly oneOf: readonly [{
|
|
369
|
+
readonly $ref: "#/$defs/workflowTaskRef";
|
|
370
|
+
}, {
|
|
371
|
+
readonly $ref: "#/$defs/queryTaskRef";
|
|
372
|
+
}, {
|
|
373
|
+
readonly $ref: "#/$defs/activityTaskRef";
|
|
374
|
+
}];
|
|
375
|
+
};
|
|
376
|
+
readonly historyPage: {
|
|
377
|
+
readonly type: "object";
|
|
378
|
+
readonly required: readonly ["events", "from", "nextAfter", "hasMore"];
|
|
379
|
+
readonly properties: {
|
|
380
|
+
readonly events: {
|
|
381
|
+
readonly type: "array";
|
|
382
|
+
readonly items: {
|
|
383
|
+
readonly type: "object";
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
readonly from: {
|
|
387
|
+
readonly type: "integer";
|
|
388
|
+
readonly minimum: 1;
|
|
389
|
+
};
|
|
390
|
+
readonly nextAfter: {
|
|
391
|
+
readonly oneOf: readonly [{
|
|
392
|
+
readonly type: "null";
|
|
393
|
+
}, {
|
|
394
|
+
readonly type: "integer";
|
|
395
|
+
readonly minimum: 1;
|
|
396
|
+
}];
|
|
397
|
+
};
|
|
398
|
+
readonly hasMore: {
|
|
399
|
+
readonly type: "boolean";
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
readonly additionalProperties: false;
|
|
403
|
+
};
|
|
404
|
+
readonly queryRequests: {
|
|
405
|
+
readonly type: "array";
|
|
406
|
+
readonly items: {
|
|
407
|
+
readonly type: "object";
|
|
408
|
+
readonly required: readonly ["queryId", "name"];
|
|
409
|
+
readonly properties: {
|
|
410
|
+
readonly queryId: {
|
|
411
|
+
readonly type: "string";
|
|
412
|
+
readonly minLength: 1;
|
|
413
|
+
readonly maxLength: 256;
|
|
414
|
+
};
|
|
415
|
+
readonly name: {
|
|
416
|
+
readonly type: "string";
|
|
417
|
+
readonly minLength: 1;
|
|
418
|
+
readonly maxLength: 256;
|
|
419
|
+
};
|
|
420
|
+
readonly args: {};
|
|
421
|
+
};
|
|
422
|
+
readonly additionalProperties: false;
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
readonly queryResults: {
|
|
426
|
+
readonly type: "array";
|
|
427
|
+
readonly items: {
|
|
428
|
+
readonly type: "object";
|
|
429
|
+
readonly required: readonly ["queryId"];
|
|
430
|
+
readonly properties: {
|
|
431
|
+
readonly queryId: {
|
|
432
|
+
readonly type: "string";
|
|
433
|
+
readonly minLength: 1;
|
|
434
|
+
readonly maxLength: 256;
|
|
435
|
+
};
|
|
436
|
+
readonly value: {};
|
|
437
|
+
readonly error: {
|
|
438
|
+
readonly type: "string";
|
|
439
|
+
};
|
|
440
|
+
readonly rejected: {
|
|
441
|
+
readonly type: "boolean";
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
readonly additionalProperties: false;
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
readonly hello: Record<string, unknown>;
|
|
448
|
+
readonly ping: Record<string, unknown>;
|
|
449
|
+
readonly pollers: Record<string, unknown>;
|
|
450
|
+
readonly taskResult: {
|
|
451
|
+
readonly oneOf: readonly [Record<string, unknown>, Record<string, unknown>, Record<string, unknown>];
|
|
452
|
+
};
|
|
453
|
+
readonly taskFailed: {
|
|
454
|
+
readonly oneOf: readonly [Record<string, unknown>, Record<string, unknown>];
|
|
455
|
+
};
|
|
456
|
+
readonly heartbeat: Record<string, unknown>;
|
|
457
|
+
readonly workerHeartbeat: Record<string, unknown>;
|
|
458
|
+
readonly req: Record<string, unknown>;
|
|
459
|
+
readonly bye: Record<string, unknown>;
|
|
460
|
+
readonly welcome: Record<string, unknown>;
|
|
461
|
+
readonly task: {
|
|
462
|
+
readonly oneOf: readonly [Record<string, unknown>, Record<string, unknown>, Record<string, unknown>];
|
|
463
|
+
};
|
|
464
|
+
readonly heartbeatAck: Record<string, unknown>;
|
|
465
|
+
readonly cancel: Record<string, unknown>;
|
|
466
|
+
readonly res: {
|
|
467
|
+
readonly if: {
|
|
468
|
+
readonly properties: {
|
|
469
|
+
readonly ok: {
|
|
470
|
+
readonly const: false;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
readonly required: readonly ["ok"];
|
|
474
|
+
};
|
|
475
|
+
readonly then: {
|
|
476
|
+
readonly required: readonly ["error"];
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
readonly pong: Record<string, unknown>;
|
|
480
|
+
readonly workerFrame: {
|
|
481
|
+
readonly oneOf: readonly [{
|
|
482
|
+
readonly $ref: "#/$defs/hello";
|
|
483
|
+
}, {
|
|
484
|
+
readonly $ref: "#/$defs/ping";
|
|
485
|
+
}, {
|
|
486
|
+
readonly $ref: "#/$defs/pollers";
|
|
487
|
+
}, {
|
|
488
|
+
readonly $ref: "#/$defs/taskResult";
|
|
489
|
+
}, {
|
|
490
|
+
readonly $ref: "#/$defs/taskFailed";
|
|
491
|
+
}, {
|
|
492
|
+
readonly $ref: "#/$defs/heartbeat";
|
|
493
|
+
}, {
|
|
494
|
+
readonly $ref: "#/$defs/workerHeartbeat";
|
|
495
|
+
}, {
|
|
496
|
+
readonly $ref: "#/$defs/req";
|
|
497
|
+
}, {
|
|
498
|
+
readonly $ref: "#/$defs/bye";
|
|
499
|
+
}];
|
|
500
|
+
};
|
|
501
|
+
readonly serviceFrame: {
|
|
502
|
+
readonly oneOf: readonly [{
|
|
503
|
+
readonly $ref: "#/$defs/welcome";
|
|
504
|
+
}, {
|
|
505
|
+
readonly $ref: "#/$defs/task";
|
|
506
|
+
}, {
|
|
507
|
+
readonly $ref: "#/$defs/heartbeatAck";
|
|
508
|
+
}, {
|
|
509
|
+
readonly $ref: "#/$defs/cancel";
|
|
510
|
+
}, {
|
|
511
|
+
readonly $ref: "#/$defs/res";
|
|
512
|
+
}, {
|
|
513
|
+
readonly $ref: "#/$defs/pong";
|
|
514
|
+
}];
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
};
|
|
7
518
|
|
|
8
519
|
type CommandValidation = {
|
|
9
520
|
ok: true;
|
|
@@ -15,10 +526,17 @@ type CommandValidation = {
|
|
|
15
526
|
};
|
|
16
527
|
interface ValidateCommandsOptions {
|
|
17
528
|
/**
|
|
18
|
-
* Which commands are enabled
|
|
19
|
-
* `
|
|
529
|
+
* Which commands are enabled: a feature set (C-GATE), or the R1 release
|
|
530
|
+
* levels `core` (default, the Phase B core set) and `parity` (adds the
|
|
531
|
+
* parity commands). With a release level Phase C commands are always
|
|
532
|
+
* refused; with a feature set the `c.*` features decide.
|
|
533
|
+
*/
|
|
534
|
+
enabled?: CommandGate;
|
|
535
|
+
/**
|
|
536
|
+
* What the lease already granted. A relief command (see `isReliefCommand`)
|
|
537
|
+
* passes the gate even when its feature is not enabled.
|
|
20
538
|
*/
|
|
21
|
-
|
|
539
|
+
relief?: CommandRelief;
|
|
22
540
|
/** Largest batch. Default 1000 (the workers' limit). */
|
|
23
541
|
maxCommands?: number;
|
|
24
542
|
}
|
|
@@ -46,6 +564,18 @@ declare function validateHistoryFile(value: unknown): {
|
|
|
46
564
|
ok: boolean;
|
|
47
565
|
issues: HistoryIssue[];
|
|
48
566
|
};
|
|
567
|
+
/**
|
|
568
|
+
* Validate one worker bridge frame (protocol 2) against
|
|
569
|
+
* `bridge-v2.schema.json`. The nested commands, events and failures are
|
|
570
|
+
* checked by their own schemas.
|
|
571
|
+
*/
|
|
572
|
+
declare function validateBridgeFrame(value: unknown): {
|
|
573
|
+
ok: true;
|
|
574
|
+
frame: BridgeFrame;
|
|
575
|
+
} | {
|
|
576
|
+
ok: false;
|
|
577
|
+
issues: HistoryIssue[];
|
|
578
|
+
};
|
|
49
579
|
/** A compiled validator for a workflow's input, output, signal or update payload schema. */
|
|
50
580
|
type PayloadValidator = (value: unknown) => {
|
|
51
581
|
ok: true;
|
|
@@ -89,6 +619,39 @@ type RetryDecision = {
|
|
|
89
619
|
declare function computeRetryDelay(policy: RetryPolicy, attempt: number, failure?: Failure): RetryDecision;
|
|
90
620
|
/** A copy of `policy` with the defaults filled in, as the SDK writes it into a command. */
|
|
91
621
|
declare function explicitRetryPolicy(policy: Partial<RetryPolicy> | undefined): RetryPolicy;
|
|
622
|
+
/** Why a run is or is not started again under its run-level retry policy (11 §2.17). */
|
|
623
|
+
type RunRetryDecision = {
|
|
624
|
+
retry: true;
|
|
625
|
+
delayMs: number;
|
|
626
|
+
} | {
|
|
627
|
+
retry: false;
|
|
628
|
+
reason: 'noPolicy' | 'nonRetryable' | 'executionTimeout' | 'typeDenied' | 'errorTypeNotListed' | 'maxAttempts';
|
|
629
|
+
};
|
|
630
|
+
/**
|
|
631
|
+
* Whether a DURABLE_FN run whose attempt `attempt` (1-based) just failed, or
|
|
632
|
+
* timed out (`failure.timeoutType` `WORKFLOW_RUN`), is started again, and
|
|
633
|
+
* after how long. An execution timeout (`WORKFLOW_EXECUTION`) bounds the whole
|
|
634
|
+
* chain and is never retried; cancellation and termination never reach this
|
|
635
|
+
* function. The backoff is the activity backoff over the run policy.
|
|
636
|
+
*/
|
|
637
|
+
declare function computeRunRetryDelay(policy: RunRetryPolicy | undefined, attempt: number, failure: Failure): RunRetryDecision;
|
|
638
|
+
/** The run retry policy with its defaults (Temporal's: 1 s, x2, at most 100 s, unlimited attempts). */
|
|
639
|
+
declare function explicitRunRetryPolicy(policy: Partial<RunRetryPolicy>): RunRetryPolicy;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* The bucket of a gradual rollout (11 §2.27): automatic starts hash
|
|
643
|
+
* `workflowId ?? runId` into 0-99 and take the rollout's `toVersion` when the
|
|
644
|
+
* bucket is below `percent`. The service's version resolution and the tests
|
|
645
|
+
* share this function, so a fixed key set splits the same way everywhere.
|
|
646
|
+
*
|
|
647
|
+
* Pure JavaScript, no I/O: FNV-1a (32 bit) over the UTF-8 bytes of the key.
|
|
648
|
+
*/
|
|
649
|
+
/** FNV-1a, 32 bit, of the UTF-8 bytes of `key`, as an unsigned integer. */
|
|
650
|
+
declare function fnv1a32(key: string): number;
|
|
651
|
+
/** The rollout bucket of a key: `fnv1a32(key) % 100`, an integer in 0-99. */
|
|
652
|
+
declare function rolloutBucket(key: string): number;
|
|
653
|
+
/** True when a start with this key takes the rollout's target version. */
|
|
654
|
+
declare function inRollout(key: string, percent: number): boolean;
|
|
92
655
|
|
|
93
656
|
/**
|
|
94
657
|
* The activity allow-list (C-ALLOW): which node types `ctx.run` may schedule.
|
|
@@ -114,8 +677,23 @@ declare const ACTIVITY_NODE_ALLOWLIST: {
|
|
|
114
677
|
/** Non-built-in node types (store and registry nodes) are allowed. */
|
|
115
678
|
readonly external: "allowed";
|
|
116
679
|
};
|
|
680
|
+
/**
|
|
681
|
+
* Built-in node types that may run as activities only with asynchronous
|
|
682
|
+
* activity completion (Phase C, H5, `fluidgrids.run-control`): the attempt
|
|
683
|
+
* parks and a person's answer completes it. `internal:wait` stays refused.
|
|
684
|
+
*/
|
|
685
|
+
declare const ACTIVITY_ASYNC_COMPLETION_ALLOWLIST: ReadonlySet<string>;
|
|
686
|
+
/** Options of {@link isActivityNodeTypeAllowed} and {@link assertActivityNodeType}. */
|
|
687
|
+
interface ActivityNodeTypeOptions {
|
|
688
|
+
/**
|
|
689
|
+
* True when the service enables asynchronous activity completion for the
|
|
690
|
+
* run (`fluidgrids.run-control`): admits `internal:send-and-wait` (H5).
|
|
691
|
+
* Default false, the Phase B allow-list.
|
|
692
|
+
*/
|
|
693
|
+
asyncCompletion?: boolean;
|
|
694
|
+
}
|
|
117
695
|
/** True when `nodeType` may run as a durable activity. */
|
|
118
|
-
declare function isActivityNodeTypeAllowed(nodeType: string): boolean;
|
|
696
|
+
declare function isActivityNodeTypeAllowed(nodeType: string, options?: ActivityNodeTypeOptions): boolean;
|
|
119
697
|
/** Raised by {@link assertActivityNodeType}. Non-retryable, error type `VALIDATION`. */
|
|
120
698
|
declare class ActivityNodeTypeNotAllowedError extends Error {
|
|
121
699
|
readonly nodeType: string;
|
|
@@ -125,7 +703,7 @@ declare class ActivityNodeTypeNotAllowedError extends Error {
|
|
|
125
703
|
constructor(nodeType: string);
|
|
126
704
|
}
|
|
127
705
|
/** Throw {@link ActivityNodeTypeNotAllowedError} unless `nodeType` may run as an activity. */
|
|
128
|
-
declare function assertActivityNodeType(nodeType: string): void;
|
|
706
|
+
declare function assertActivityNodeType(nodeType: string, options?: ActivityNodeTypeOptions): void;
|
|
129
707
|
|
|
130
708
|
/**
|
|
131
709
|
* Defaults the service, the workers and the SDK must apply the same way.
|
|
@@ -154,4 +732,4 @@ declare const CHILD_DEFAULT_PARENT_CLOSE_POLICY: Readonly<{
|
|
|
154
732
|
*/
|
|
155
733
|
declare const CHILD_DEFAULT_CANCELLATION_TYPE: ChildCancellationType;
|
|
156
734
|
|
|
157
|
-
export { ACTIVITY_INTERNAL_ALLOWLIST, ACTIVITY_NODE_ALLOWLIST, ACTIVITY_NODE_DENYLIST, ActivityNodeTypeNotAllowedError, CHILD_DEFAULT_CANCELLATION_TYPE, CHILD_DEFAULT_PARENT_CLOSE_POLICY, ChildCancellationType, type CommandValidation, DEFAULT_ACTIVITY_RETRY, Failure, HistoryIssue, ParentClosePolicy, type PayloadValidator, type RetryDecision, RetryPolicy, type ValidateCommandsOptions, WorkflowCommand, WorkflowTaskFailureCause, assertActivityNodeType, codeWorkflowParentClosePolicy, compilePayloadValidator, computeRetryDelay, explicitRetryPolicy, isActivityNodeTypeAllowed, validateCommand, validateCommands, validateHistory, validateHistoryFile };
|
|
735
|
+
export { ACTIVITY_ASYNC_COMPLETION_ALLOWLIST, ACTIVITY_INTERNAL_ALLOWLIST, ACTIVITY_NODE_ALLOWLIST, ACTIVITY_NODE_DENYLIST, ActivityNodeTypeNotAllowedError, type ActivityNodeTypeOptions, type ActivityTaskFrame, type ActivityTaskRef, type ActivityTaskResultFrame, BRIDGE_IDLE_TIMEOUT_MS, BRIDGE_MAX_FRAME_BYTES, BRIDGE_MAX_HISTORY_TAIL_BYTES, BRIDGE_PATH, BRIDGE_PING_SECONDS, BRIDGE_PROTOCOL_VERSION, BRIDGE_REQUEST_METHODS, BRIDGE_V2_SCHEMA, BRIDGE_V2_SCHEMA_ID, BRIDGE_WORKER_HEARTBEAT_SECONDS, type BridgeCancelFrame, BridgeCloseCode, type BridgeCloseCodeValue, type BridgeFrame, type BridgeHeartbeatAckFrame, type BridgeHistoryPage, type BridgePongFrame, type BridgeRequestMethod, type BridgeResponseFrame, type BridgeSlotUsage, type BridgeTaskFrame, type BridgeTaskRef, type BridgeWelcomeFrame, CHILD_DEFAULT_CANCELLATION_TYPE, CHILD_DEFAULT_PARENT_CLOSE_POLICY, ChildCancellationType, CommandGate, CommandRelief, type CommandValidation, DEFAULT_ACTIVITY_RETRY, Failure, HistoryIssue, ParentClosePolicy, type PayloadValidator, QueryRequest, QueryResult, type QueryTaskFrame, type QueryTaskRef, type QueryTaskResultFrame, type RetryDecision, RetryPolicy, RunEventRecord, type RunRetryDecision, RunRetryPolicy, type ServiceFrame, type TaskFailedFrame, TaskLogLine, type TaskResultFrame, UnfinishedHandler, UpdateRequest, type ValidateCommandsOptions, type WorkerActivityHeartbeatFrame, type WorkerByeFrame, type WorkerFrame, type WorkerHeartbeatFrame, type WorkerHelloFrame, type WorkerPingFrame, type WorkerPollersFrame, type WorkerRequestFrame, WorkflowCommand, WorkflowInfoSnapshot, type WorkflowTaskFailure, WorkflowTaskFailureCause, type WorkflowTaskFrame, type WorkflowTaskRef, type WorkflowTaskResultFrame, assertActivityNodeType, codeWorkflowParentClosePolicy, compilePayloadValidator, computeRetryDelay, computeRunRetryDelay, explicitRetryPolicy, explicitRunRetryPolicy, fnv1a32, inRollout, isActivityNodeTypeAllowed, rolloutBucket, validateBridgeFrame, validateCommand, validateCommands, validateHistory, validateHistoryFile };
|