@segmentstream/ontology 0.197.0 → 0.198.0
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/CHANGELOG.md +103 -0
- package/dist/analyze.d.ts +2 -0
- package/dist/analyze.js +17 -0
- package/dist/bin/check.js +12 -0
- package/dist/bin/migrate.js +1 -1
- package/dist/connection.d.ts +109 -6
- package/dist/connection.js +132 -17
- package/dist/diagnostics.d.ts +3 -3
- package/dist/diagnostics.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/manifest.d.ts +28 -0
- package/dist/manifest.js +6 -0
- package/dist/migrate/apply.d.ts +7 -1
- package/dist/migrate/apply.js +12 -3
- package/dist/migrate/model.d.ts +8 -0
- package/dist/migrate/plan.js +14 -1
- package/dist/owned-workflows.d.ts +10 -0
- package/dist/owned-workflows.js +16 -0
- package/dist/runtime/owner-departures.d.ts +35 -0
- package/dist/runtime/owner-departures.js +64 -0
- package/dist/runtime/pipeline.d.ts +15 -1
- package/dist/runtime/pipeline.js +67 -1
- package/dist/runtime/principals.d.ts +17 -2
- package/dist/runtime/principals.js +33 -2
- package/dist/runtime/service-binding.js +17 -3
- package/dist/runtime/workflow-starts.d.ts +108 -8
- package/dist/runtime/workflow-starts.js +276 -49
- package/dist/service/agent/attachments.js +27 -6
- package/dist/service/agent/authentication.d.ts +5 -0
- package/dist/service/agent/authentication.js +1 -1
- package/dist/service/agent/task-caller.d.ts +4 -2
- package/dist/service/agent/task-caller.js +4 -2
- package/dist/service/authentication.d.ts +7 -0
- package/dist/service/authentication.js +12 -0
- package/dist/service/chat/envelope.d.ts +7 -0
- package/dist/service/chat/envelope.js +15 -0
- package/dist/service/config.d.ts +6 -0
- package/dist/service/connections.d.ts +17 -2
- package/dist/service/connections.js +21 -1
- package/dist/service/errors.js +27 -1
- package/dist/service/member-files.js +6 -0
- package/dist/service/operations.d.ts +8 -0
- package/dist/service/operations.js +11 -4
- package/dist/service/owned-connections.d.ts +80 -0
- package/dist/service/owned-connections.js +488 -0
- package/dist/service/runtime-contract.d.ts +22 -0
- package/dist/service/schemas.d.ts +2 -0
- package/dist/service/service.js +23 -2
- package/dist/service/workflow-errors.d.ts +18 -1
- package/dist/service/workflow-errors.js +51 -2
- package/dist/service/workflows.d.ts +24 -0
- package/dist/service/workflows.js +360 -50
- package/dist/start-recovery-contract.d.ts +17 -1
- package/dist/start-recovery-contract.js +11 -1
- package/dist/start-recovery.js +4 -1
- package/dist/storage/tables.d.ts +15 -0
- package/dist/storage/tables.js +21 -0
- package/dist/workflow.d.ts +20 -2
- package/package.json +1 -1
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { Cause } from "effect";
|
|
1
|
+
import { Cause, Schema } from "effect";
|
|
2
2
|
import { captureRuntimeFailure, environmentSecrets, makeRedactor, } from "../internal/diagnostics.js";
|
|
3
|
+
/**
|
|
4
|
+
* The owner of a workflow run is no longer an active member: deactivated, blocked or deleted after
|
|
5
|
+
* the run started. The step fails, and the run never acts as the workflow's user instead.
|
|
6
|
+
*/
|
|
7
|
+
export class OwnerInactive extends Schema.TaggedError()("OwnerInactive", {
|
|
8
|
+
reason: Schema.Literal("owner_inactive"),
|
|
9
|
+
message: Schema.String,
|
|
10
|
+
}) {
|
|
11
|
+
}
|
|
3
12
|
const SAFE_FAILURES = new Set([
|
|
13
|
+
"OwnerInactive",
|
|
4
14
|
"TriggerInputInvalid",
|
|
5
15
|
"WorkflowRecoveryUnavailable",
|
|
6
16
|
"ActionRejected",
|
|
@@ -15,6 +25,7 @@ const SAFE_FAILURES = new Set([
|
|
|
15
25
|
]);
|
|
16
26
|
const DEPLOYMENT_FAILURES = new Set(["DeploymentSwitching", "DeploymentInterrupted"]);
|
|
17
27
|
const DETERMINISTIC_FAILURES = new Set([
|
|
28
|
+
"OwnerInactive",
|
|
18
29
|
"TriggerInputInvalid",
|
|
19
30
|
"PermissionDenied",
|
|
20
31
|
"ScopeViolated",
|
|
@@ -23,6 +34,18 @@ const DETERMINISTIC_FAILURES = new Set([
|
|
|
23
34
|
"AgentTaskRefused",
|
|
24
35
|
"DeploymentInterrupted",
|
|
25
36
|
]);
|
|
37
|
+
/**
|
|
38
|
+
* Run failures the Workflow runtime classifies itself when a run outgrows a per-run limit. The
|
|
39
|
+
* runtime builds these errors itself (`MaxEventsExceededError`, and the `FatalError`s of its replay
|
|
40
|
+
* budget and run delivery count), so their first line states the limit and carries no workspace
|
|
41
|
+
* data; the hint below it names the runtime's environment, which workspaces do not set.
|
|
42
|
+
*/
|
|
43
|
+
const RUNTIME_LIMIT_FAILURES = new Set([
|
|
44
|
+
"MAX_EVENTS_EXCEEDED",
|
|
45
|
+
"REPLAY_TIMEOUT",
|
|
46
|
+
"MAX_DELIVERIES_EXCEEDED",
|
|
47
|
+
]);
|
|
48
|
+
const MAX_RUNTIME_MESSAGE_CHARS = 300;
|
|
26
49
|
const TAG = /^[A-Za-z][A-Za-z0-9_]{0,99}$/;
|
|
27
50
|
const ID = /^[A-Za-z0-9_.:-]{1,200}$/;
|
|
28
51
|
function record(value) {
|
|
@@ -69,7 +92,9 @@ export function stepFailure(cause, requestId, step, workflow, credentials) {
|
|
|
69
92
|
message: publicMessage === undefined ? null : redact(publicMessage),
|
|
70
93
|
reference: requestId,
|
|
71
94
|
...deploymentFields(tag, failure),
|
|
72
|
-
...(tag === "ConnectionError"
|
|
95
|
+
...((tag === "ConnectionError" || tag === "OwnerInactive") &&
|
|
96
|
+
typeof failure?.reason === "string" &&
|
|
97
|
+
TAG.test(failure.reason)
|
|
73
98
|
? { reason: failure.reason }
|
|
74
99
|
: {}),
|
|
75
100
|
...(tag === "ConnectionError" &&
|
|
@@ -179,3 +204,27 @@ export function workflowErrorView(value) {
|
|
|
179
204
|
const tag = typeof name === "string" && TAG.test(name) ? name : null;
|
|
180
205
|
return publicError(item ?? {}, tag);
|
|
181
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* A run's error, with the runtime's own classification when it failed the run for outgrowing a
|
|
209
|
+
* per-run limit: the code (`MAX_EVENTS_EXCEEDED`, `REPLAY_TIMEOUT`, `MAX_DELIVERIES_EXCEEDED`) and
|
|
210
|
+
* the first line of the runtime's message, which names the limit. Other failures are unchanged.
|
|
211
|
+
*/
|
|
212
|
+
export function workflowRunErrorView(value, errorCode) {
|
|
213
|
+
const view = workflowErrorView(value);
|
|
214
|
+
if (typeof errorCode !== "string" || !RUNTIME_LIMIT_FAILURES.has(errorCode)) {
|
|
215
|
+
return view;
|
|
216
|
+
}
|
|
217
|
+
const item = record(value);
|
|
218
|
+
const firstLine = value instanceof Error || typeof item?.message === "string"
|
|
219
|
+
? String(item.message)
|
|
220
|
+
.split("\n", 1)[0]
|
|
221
|
+
.trim()
|
|
222
|
+
: "";
|
|
223
|
+
return {
|
|
224
|
+
...(view ?? { tag: null, message: null, code: errorCode }),
|
|
225
|
+
code: errorCode,
|
|
226
|
+
message: firstLine === ""
|
|
227
|
+
? (view?.message ?? null)
|
|
228
|
+
: makeRedactor(environmentSecrets(process.env))(firstLine).slice(0, MAX_RUNTIME_MESSAGE_CHARS),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
@@ -6,6 +6,7 @@ import type { Ontology } from "../ontology.js";
|
|
|
6
6
|
import { type WorkflowStarter } from "../runtime/workflow-starts.js";
|
|
7
7
|
import { type WorkflowFunction } from "../workflow.js";
|
|
8
8
|
import { type WorkflowSdk } from "../workflow-runtime.js";
|
|
9
|
+
import type { EligibleOwners } from "./owned-connections.js";
|
|
9
10
|
import { type AgentTransport } from "./agent/task-start.js";
|
|
10
11
|
import { type SessionExchange, type TokenVerifier } from "./authentication.js";
|
|
11
12
|
import type { AfterCommitHook } from "./config.js";
|
|
@@ -32,6 +33,8 @@ export interface WorkflowRunRecord {
|
|
|
32
33
|
readonly attributes?: Readonly<Record<string, string>> | undefined;
|
|
33
34
|
readonly deploymentId?: string;
|
|
34
35
|
readonly error?: unknown;
|
|
36
|
+
/** The runtime's classification of a failed run, such as `MAX_EVENTS_EXCEEDED`. */
|
|
37
|
+
readonly errorCode?: string | undefined;
|
|
35
38
|
}
|
|
36
39
|
/** A step of a run, from the Workflow SDK's step record. */
|
|
37
40
|
export interface WorkflowStepRecord {
|
|
@@ -190,6 +193,11 @@ interface WorkflowsOptions {
|
|
|
190
193
|
readonly agentOrigin?: string | undefined;
|
|
191
194
|
/** How `agentTask` calls the app's agent: `fetch` by default. */
|
|
192
195
|
readonly agentTransport?: AgentTransport | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Reads the users eligible for a scheduled run of an owned workflow from SegmentStream. Without
|
|
198
|
+
* it, a cron on an owned workflow answers 503 and starts nothing.
|
|
199
|
+
*/
|
|
200
|
+
readonly eligibleOwners?: EligibleOwners | undefined;
|
|
193
201
|
}
|
|
194
202
|
/**
|
|
195
203
|
* Starts the runs action triggers decide, through the engine on the ontology's queue: the row's
|
|
@@ -202,6 +210,22 @@ interface WorkflowsOptions {
|
|
|
202
210
|
* Requests that arrive while a start is in flight wait for it instead of starting their own.
|
|
203
211
|
*/
|
|
204
212
|
export declare function workflowStarter(ontology: Ontology, engine: WorkflowEngine, clock?: () => number): WorkflowStarter["Service"];
|
|
213
|
+
/**
|
|
214
|
+
* How early a cron delivery may arrive and still be for the instant it precedes. Early deliveries
|
|
215
|
+
* are milliseconds to seconds early; a delivery this much short of the cron's period late is for
|
|
216
|
+
* the next instant.
|
|
217
|
+
*/
|
|
218
|
+
export declare const CRON_DELIVERY_SKEW_MS = 5000;
|
|
219
|
+
/**
|
|
220
|
+
* The instant a cron delivery is for: the latest at which the expression fires, at most
|
|
221
|
+
* {@link CRON_DELIVERY_SKEW_MS} after the delivery and less than an hour before it. A delivery that
|
|
222
|
+
* arrives a little early, on time, late or again names the same instant. One late by the cron's
|
|
223
|
+
* period less {@link CRON_DELIVERY_SKEW_MS} or more names the next instant and counts as its
|
|
224
|
+
* delivery: each owner gets at most one run per instant, and the instant it missed gets none. A
|
|
225
|
+
* delivery with no such instant, as an operator's far from the schedule, is for the minute it
|
|
226
|
+
* arrived in.
|
|
227
|
+
*/
|
|
228
|
+
export declare function scheduledMinute(expression: string, now: Date): string;
|
|
205
229
|
/** The route Vercel calls for a cron trigger: `/api/ontology/workflows/<workflow>/triggers/<trigger>`. */
|
|
206
230
|
export declare function triggerPath(workflow: string, trigger: string): string;
|
|
207
231
|
/** The route Vercel calls every five minutes when the manifest declares an action trigger. */
|