@segmentstream/ontology 0.197.1 → 0.199.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/dist/analyze.d.ts +2 -0
  3. package/dist/analyze.js +17 -0
  4. package/dist/bin/check.js +12 -0
  5. package/dist/bin/migrate.js +1 -1
  6. package/dist/connection.d.ts +109 -6
  7. package/dist/connection.js +132 -17
  8. package/dist/diagnostics.d.ts +3 -3
  9. package/dist/diagnostics.js +2 -0
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +1 -1
  12. package/dist/manifest.d.ts +28 -0
  13. package/dist/manifest.js +6 -0
  14. package/dist/migrate/apply.d.ts +7 -1
  15. package/dist/migrate/apply.js +12 -3
  16. package/dist/migrate/model.d.ts +8 -0
  17. package/dist/migrate/plan.js +14 -1
  18. package/dist/owned-workflows.d.ts +10 -0
  19. package/dist/owned-workflows.js +16 -0
  20. package/dist/runtime/agents.js +2 -0
  21. package/dist/runtime/owner-departures.d.ts +35 -0
  22. package/dist/runtime/owner-departures.js +64 -0
  23. package/dist/runtime/pipeline.d.ts +15 -1
  24. package/dist/runtime/pipeline.js +67 -1
  25. package/dist/runtime/principals.d.ts +17 -2
  26. package/dist/runtime/principals.js +33 -2
  27. package/dist/runtime/service-binding.js +17 -3
  28. package/dist/runtime/workflow-starts.d.ts +108 -8
  29. package/dist/runtime/workflow-starts.js +276 -49
  30. package/dist/service/agent/attachments.js +27 -6
  31. package/dist/service/agent/authentication.d.ts +5 -0
  32. package/dist/service/agent/authentication.js +1 -1
  33. package/dist/service/agent/protocol.d.ts +4 -0
  34. package/dist/service/agent/protocol.js +4 -0
  35. package/dist/service/agent/server.js +7 -4
  36. package/dist/service/agent/task-caller.d.ts +4 -2
  37. package/dist/service/agent/task-caller.js +4 -2
  38. package/dist/service/authentication.d.ts +7 -0
  39. package/dist/service/authentication.js +12 -0
  40. package/dist/service/channel/telegram-pairing.d.ts +9 -0
  41. package/dist/service/channel/telegram-pairing.js +114 -0
  42. package/dist/service/chat/envelope.d.ts +7 -0
  43. package/dist/service/chat/envelope.js +15 -0
  44. package/dist/service/chat/providers/telegram.d.ts +2 -0
  45. package/dist/service/chat/providers/telegram.js +1 -1
  46. package/dist/service/config.d.ts +6 -0
  47. package/dist/service/connections.d.ts +17 -2
  48. package/dist/service/connections.js +21 -1
  49. package/dist/service/errors.js +27 -1
  50. package/dist/service/member-files.js +6 -0
  51. package/dist/service/operations.d.ts +8 -0
  52. package/dist/service/operations.js +11 -4
  53. package/dist/service/owned-connections.d.ts +80 -0
  54. package/dist/service/owned-connections.js +488 -0
  55. package/dist/service/runtime-contract.d.ts +34 -0
  56. package/dist/service/schemas.d.ts +2 -0
  57. package/dist/service/service.js +26 -2
  58. package/dist/service/workflow-errors.d.ts +12 -1
  59. package/dist/service/workflow-errors.js +15 -2
  60. package/dist/service/workflows.d.ts +22 -0
  61. package/dist/service/workflows.js +358 -48
  62. package/dist/start-recovery-contract.d.ts +17 -1
  63. package/dist/start-recovery-contract.js +11 -1
  64. package/dist/start-recovery.js +4 -1
  65. package/dist/storage/tables.d.ts +15 -0
  66. package/dist/storage/tables.js +21 -0
  67. package/dist/workflow.d.ts +20 -2
  68. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { Cause } from "effect";
1
+ import { Cause, Schema } from "effect";
2
2
  import type { WorkflowStepContext } from "../workflow-runtime.js";
3
3
  /** Public diagnostics contain declared safe messages, never the operator report or inputs. */
4
4
  export interface WorkflowErrorView {
@@ -15,6 +15,16 @@ export interface WorkflowErrorView {
15
15
  readonly appliedDeploymentId?: string;
16
16
  readonly generation?: string;
17
17
  }
18
+ declare const OwnerInactive_base: Schema.Class<OwnerInactive, Schema.TaggedStruct<"OwnerInactive", {
19
+ readonly reason: Schema.Literal<"owner_inactive">;
20
+ readonly message: Schema.String;
21
+ }>, Cause.YieldableError>;
22
+ /**
23
+ * The owner of a workflow run is no longer an active member: deactivated, blocked or deleted after
24
+ * the run started. The step fails, and the run never acts as the workflow's user instead.
25
+ */
26
+ export declare class OwnerInactive extends OwnerInactive_base {
27
+ }
18
28
  /** The SDK preserves Error.cause; custom Error properties are otherwise discarded. */
19
29
  export declare class WorkflowStepFailed extends Error {
20
30
  readonly fatal: boolean;
@@ -30,3 +40,4 @@ export declare function workflowErrorView(value: unknown): WorkflowErrorView | n
30
40
  * the first line of the runtime's message, which names the limit. Other failures are unchanged.
31
41
  */
32
42
  export declare function workflowRunErrorView(value: unknown, errorCode: unknown): WorkflowErrorView | null;
43
+ export {};
@@ -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",
@@ -81,7 +92,9 @@ export function stepFailure(cause, requestId, step, workflow, credentials) {
81
92
  message: publicMessage === undefined ? null : redact(publicMessage),
82
93
  reference: requestId,
83
94
  ...deploymentFields(tag, failure),
84
- ...(tag === "ConnectionError" && typeof failure?.reason === "string" && TAG.test(failure.reason)
95
+ ...((tag === "ConnectionError" || tag === "OwnerInactive") &&
96
+ typeof failure?.reason === "string" &&
97
+ TAG.test(failure.reason)
85
98
  ? { reason: failure.reason }
86
99
  : {}),
87
100
  ...(tag === "ConnectionError" &&
@@ -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";
@@ -192,6 +193,11 @@ interface WorkflowsOptions {
192
193
  readonly agentOrigin?: string | undefined;
193
194
  /** How `agentTask` calls the app's agent: `fetch` by default. */
194
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;
195
201
  }
196
202
  /**
197
203
  * Starts the runs action triggers decide, through the engine on the ontology's queue: the row's
@@ -204,6 +210,22 @@ interface WorkflowsOptions {
204
210
  * Requests that arrive while a start is in flight wait for it instead of starting their own.
205
211
  */
206
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;
207
229
  /** The route Vercel calls for a cron trigger: `/api/ontology/workflows/<workflow>/triggers/<trigger>`. */
208
230
  export declare function triggerPath(workflow: string, trigger: string): string;
209
231
  /** The route Vercel calls every five minutes when the manifest declares an action trigger. */