@sanity/workflow-engine 0.32.0 → 0.34.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/dist/index.d.ts CHANGED
@@ -102,7 +102,7 @@ export declare function aclPathForResource(
102
102
  *
103
103
  * @interface
104
104
  */
105
- export declare type Action = ActionFields<Op, string[]> & {
105
+ export declare type Action = ActionFields<Op, string[], Effect> & {
106
106
  roles?: string[] | undefined;
107
107
  };
108
108
 
@@ -196,7 +196,7 @@ export declare interface ActionEvaluation {
196
196
  }
197
197
 
198
198
  /** @inline */
199
- declare type ActionFields<TOp, TGroup> = {
199
+ declare type ActionFields<TOp, TGroup, TEffect> = {
200
200
  name: string;
201
201
  semantics?: ActionSemantic[] | undefined;
202
202
  title?: string | undefined;
@@ -206,7 +206,7 @@ declare type ActionFields<TOp, TGroup> = {
206
206
  filter?: string | undefined;
207
207
  params?: ActionParam[] | undefined;
208
208
  ops?: TOp[] | undefined;
209
- effects?: Effect[] | undefined;
209
+ effects?: TEffect[] | undefined;
210
210
  spawn?: Subworkflows | undefined;
211
211
  };
212
212
 
@@ -551,15 +551,14 @@ export declare interface ActivityEvaluation {
551
551
  */
552
552
  scopedOut: boolean;
553
553
  /**
554
- * The activity's unmet {@link Activity.requirements}, with authored display copy — present iff at least
555
- * one is unmet. The activity's own readiness summary: a consumer can explain why
556
- * the whole activity is gated without inspecting each action (every action also
557
- * carries the matching `requirements-unmet` `disabledReason`).
554
+ * Unmet authored activity requirements and required-reference readability checks.
555
+ * Present when at least one is unmet. Required-reference descriptors use
556
+ * `field:<name>` and the field's declared title when available.
558
557
  */
559
558
  unmetRequirements?: RequirementDescriptor[];
560
- /** Derived state per declared requirement, keyed by requirement name.
561
- * Present iff the activity declares requirements; `unmetRequirements`
562
- * contains descriptors for exactly the requirements whose insight isn't satisfied. */
559
+ /** Derived state per authored requirement, keyed by its declared name.
560
+ * Present when the activity declares requirements. Unmet authored requirements
561
+ * appear in `unmetRequirements`; required-reference checks have no insight entry. */
563
562
  requirementInsights?: Record<string, ConditionInsight>;
564
563
  /** Derived state of the activity's `filter` existence gate. Present iff
565
564
  * declared. Advisory read: the engine's stage entry owns the gate itself. */
@@ -642,7 +641,13 @@ export declare interface Actor {
642
641
  */
643
642
  export declare const ACTOR_KINDS: readonly ["person", "agent", "system"];
644
643
 
645
- /** Runtime role check; like alias expansion, it expands only the required side. */
644
+ /**
645
+ * Checks whether an actor role fulfills `required`, directly or through one
646
+ * level of aliases. Pass `roleAliases` from a definition returned by
647
+ * {@link define.defineWorkflow | defineWorkflow}; its universal aliases are
648
+ * normalized. A raw authored `"*"` entry is not expanded here.
649
+ * This role check is advisory.
650
+ */
646
651
  export declare function actorFulfillsRole({
647
652
  actorRoles,
648
653
  required,
@@ -682,6 +687,14 @@ export declare type ActorResolution<User> =
682
687
  readonly actor: Actor;
683
688
  };
684
689
 
690
+ /** Missing-reference evidence accompanying another primary fault, for workspace renderers only.
691
+ * @internal
692
+ */
693
+ export declare function _additionalMissingDocuments(
694
+ diagnosis: Diagnosis,
695
+ documents: MissingDocument[] | undefined,
696
+ ): MissingDocument[];
697
+
685
698
  export { analyzeCondition };
686
699
 
687
700
  /** Lake `identity()` sentinel for unauthenticated callers. */
@@ -736,11 +749,13 @@ export declare function assertReaderModelAcknowledgement(
736
749
  ): asserts expectedMinReaderModel is number;
737
750
 
738
751
  /**
739
- * One member of an assignment entry's value, matched by the inbox reverse-query
740
- * and rendered `$assigned` gate. A `role` member names a capability
741
- * (fulfilled by whoever deploys that role), not a concrete principal — which
742
- * is what distinguishes it from {@link Actor}. `id` here is a SYSTEM
743
- * identifier (a principal), not authored identity.
752
+ * One member of an `assignee` or `assignees` field. For a user member, pass a
753
+ * human's account-global `sanityUserId`, not a project-scoped user ID. Robot
754
+ * IDs are rejected.
755
+ *
756
+ * A role member identifies a project role, not an individual {@link Actor}.
757
+ * Direct user members take ownership ahead of role members. Role aliases apply
758
+ * to `$assigned` authorization, but inbox routing uses literal project roles.
744
759
  */
745
760
  export declare type Assignee =
746
761
  | {
@@ -859,6 +874,23 @@ export declare type AuthoringActivity = ActivityFields<
859
874
  */
860
875
  export declare type AuthoringEditable = true | string[] | string;
861
876
 
877
+ /**
878
+ * An {@link Effect} whose `retry` block may omit its `kind`, plus the
879
+ * authoring-only `runtime` block that says where the generated runtime hosts
880
+ * this handler. `retry` is stored; `runtime` is stripped before the deploy
881
+ * writes the definition.
882
+ *
883
+ * @interface
884
+ */
885
+ export declare type AuthoringEffect = EffectFields<AuthoringEffectRetry> & {
886
+ runtime?: EffectRuntimeBlock | undefined;
887
+ };
888
+
889
+ /** An {@link EffectRetry} whose omitted `kind` defaults to `engine`. */
890
+ export declare type AuthoringEffectRetry = EffectRetryFields & {
891
+ kind?: EffectRetryKind | undefined;
892
+ };
893
+
862
894
  /**
863
895
  * A raw field entry or one of the authoring-only field sugars. `todoList`
864
896
  * expands to an array of objects with `label`, `status`, optional `assignee`,
@@ -866,6 +898,7 @@ export declare type AuthoringEditable = true | string[] | string;
866
898
  * `notes` expands to an array of audit-shaped objects with `body`, `actor`,
867
899
  * and `at` fields. Sugar type names are compiled away and never become stored
868
900
  * field kinds.
901
+ * See {@link FieldEntry} for scope, required-input, and field-type constraints.
869
902
  */
870
903
  export declare type AuthoringFieldEntry =
871
904
  | AuthoringRawFieldEntry
@@ -899,8 +932,22 @@ declare const AuthoringFieldRefSchema: v.StrictObjectSchema<
899
932
  >;
900
933
 
901
934
  /**
902
- * {@link Guard}'s contract as authored: `match.idRefs` and `metadata` carry
903
- * typed {@link GuardRead} values that deploy resolves to bare ones.
935
+ * A stage's content mutation guard. Its name must be unique across the whole
936
+ * definition and use lowercase letters, digits, and dashes, starting with a
937
+ * letter or digit. `match.actions` must contain at least one action.
938
+ *
939
+ * `match.types` intersects the ID criteria. Within the ID criteria, matching
940
+ * either `idRefs` or `idPatterns` is sufficient. Omitted or empty optional
941
+ * criteria do not constrain the match. `idRefs` uses typed {@link GuardRead}s.
942
+ * Patterns use resource-local document-ID characters and `*` wildcards.
943
+ * A release-version pattern is rejected if translating it for a lifecycle
944
+ * action would broaden it to every document.
945
+ *
946
+ * `predicate` is delta-mode GROQ over `document`, `guard`, and `mutation`;
947
+ * see {@link GUARD_PREDICATE_VARS}. Only a strict `true` allows a matching
948
+ * mutation. An omitted or empty predicate denies it. `metadata` resolves
949
+ * {@link GuardRead}s into values available as `guard.metadata` in the predicate.
950
+ * Engine evaluations are advisory; the Content Lake is the enforcement point.
904
951
  *
905
952
  * @interface
906
953
  */
@@ -1019,7 +1066,11 @@ export declare type AuthoringOp =
1019
1066
  };
1020
1067
 
1021
1068
  /** @inline */
1022
- declare type AuthoringRawAction = ActionFields<AuthoringOp, GroupMembership> & {
1069
+ declare type AuthoringRawAction = ActionFields<
1070
+ AuthoringOp,
1071
+ GroupMembership,
1072
+ AuthoringEffect
1073
+ > & {
1023
1074
  roles?: string[] | undefined;
1024
1075
  status?: TerminalActivityStatus | undefined;
1025
1076
  };
@@ -1030,7 +1081,15 @@ declare type AuthoringRawFieldEntry = FieldEntryFields<
1030
1081
  GroupMembership
1031
1082
  >;
1032
1083
 
1033
- /** @interface */
1084
+ /** @inline */
1085
+ declare type AuthoringRuntimeKey = "runtime";
1086
+
1087
+ /**
1088
+ * A {@link Stage} accepting authoring fields, activities, transitions, guards,
1089
+ * and role-list editability. The same terminal-stage constraints apply.
1090
+ *
1091
+ * @interface
1092
+ */
1034
1093
  export declare type AuthoringStage = StageFields<
1035
1094
  AuthoringFieldEntry,
1036
1095
  AuthoringActivity,
@@ -1039,21 +1098,23 @@ export declare type AuthoringStage = StageFields<
1039
1098
  AuthoringEditable
1040
1099
  >;
1041
1100
 
1101
+ /** A {@link StartBlock} whose omitted `kind` defaults to `interactive`. */
1042
1102
  export declare type AuthoringStartBlock = StartFields & {
1043
1103
  kind?: StartKind | undefined;
1044
1104
  };
1045
1105
 
1046
1106
  /**
1047
- * Authoring transitions may omit `when`; desugar fills the safe,
1048
- * overwhelmingly-common trigger `"$allActivitiesDone"`. "Fire unconditionally"
1049
- * stays spellable as an explicit `when: "true"`.
1107
+ * A {@link Transition} whose `when` may be omitted, defaulting to
1108
+ * `$allActivitiesDone`. Use `when: 'true'` for an unconditional route.
1050
1109
  */
1051
1110
  export declare type AuthoringTransition = TransitionFields & {
1052
1111
  when?: string | undefined;
1053
1112
  };
1054
1113
 
1055
1114
  /**
1056
- * The authoring surface: stored primitives plus the define-time sugar.
1115
+ * The authoring surface: stored primitives plus the define-time sugar. `runtime`
1116
+ * says where the generated unattended runtime hosts this workflow, overriding
1117
+ * its deployment's kind; an effect node overrides it in turn.
1057
1118
  *
1058
1119
  * @interface
1059
1120
  */
@@ -1061,7 +1122,9 @@ export declare type AuthoringWorkflow = WorkflowFields<
1061
1122
  AuthoringFieldEntry,
1062
1123
  AuthoringStage,
1063
1124
  AuthoringStartBlock
1064
- >;
1125
+ > & {
1126
+ runtime?: RuntimeBlock | undefined;
1127
+ };
1065
1128
 
1066
1129
  /** The narratable answer at one rollup level: the verdict plus what it waits
1067
1130
  * on. `waitsOn` may be non-empty on a `yes` verdict (an effect settle is a
@@ -1224,6 +1287,15 @@ export declare interface ChoiceOption {
1224
1287
  value: ChoiceValue;
1225
1288
  }
1226
1289
 
1290
+ /**
1291
+ * A closed list of allowed non-null scalar values. The list must be nonempty,
1292
+ * with unique values and nonempty titles. Each value must satisfy the
1293
+ * receiving type and its validation bounds.
1294
+ *
1295
+ * Fields accept choices on `string`, `text`, `number`, `url`, `date`,
1296
+ * `dueDate`, `datetime`, and `dueDatetime`. Action parameters accept choices
1297
+ * on `string`, `number`, `url`, and `dateTime`.
1298
+ */
1227
1299
  export declare interface ChoiceOptions {
1228
1300
  list: ChoiceOption[];
1229
1301
  }
@@ -1279,6 +1351,14 @@ export declare function clientGuardDereference(
1279
1351
  client: Pick<WorkflowClient, "getDocument">,
1280
1352
  ): GuardDereference;
1281
1353
 
1354
+ /** @internal Shared member rows for workspace adapters; not a supported consumer API. */
1355
+ export declare interface _ClientProjectMember {
1356
+ readonly id: string;
1357
+ readonly isRobot?: boolean;
1358
+ readonly roles?: unknown;
1359
+ readonly [key: string]: unknown;
1360
+ }
1361
+
1282
1362
  /** Native project-user response returned by Sanity's project API. */
1283
1363
  export declare interface ClientProjectUser {
1284
1364
  readonly id: string;
@@ -1836,6 +1916,13 @@ export declare interface CreateEngineArgs<
1836
1916
  * option.
1837
1917
  */
1838
1918
  clock?: Clock;
1919
+ /**
1920
+ * How the engine waits out a `retry` policy's backoff between attempts.
1921
+ * Pinned once beside {@link CreateEngineArgs.clock}; omit (the default) to
1922
+ * spend real time. A deterministic harness passes one that moves its clock
1923
+ * forward instead, so a paced policy runs without waiting.
1924
+ */
1925
+ sleep?: Sleeper;
1839
1926
  /**
1840
1927
  * Product-telemetry seam, pinned once for this engine and threaded into
1841
1928
  * every verb it drives. The core engine ships no metrics pipeline — it
@@ -1863,6 +1950,8 @@ export declare function createTelemetryIntake(args: {
1863
1950
  client: TelemetryIntakeClient;
1864
1951
  projectId: string;
1865
1952
  denied?: boolean;
1953
+ /** Context merged into every event at send time. These values win on key collisions. */
1954
+ context?: Record<string, unknown>;
1866
1955
  }): TelemetryIntake;
1867
1956
 
1868
1957
  /** A define-time validated `custom.<camelCaseMeaning>` value. */
@@ -2014,10 +2103,28 @@ export declare const DATA_MODEL_CHANGES: readonly [
2014
2103
  applicability: "detectable";
2015
2104
  summary: "Singular assignee fields use member lists with at most one user and any number of roles.";
2016
2105
  }>,
2106
+ Readonly<{
2107
+ id: "required-content-references";
2108
+ introducedInModel: 10;
2109
+ minReaderModel: 10;
2110
+ documentTypes: readonly ["definition", "instance"];
2111
+ compatibility: "reader-floor";
2112
+ applicability: "detectable";
2113
+ summary: "Required content references must remain readable after initialization before actions or transitions advance.";
2114
+ }>,
2115
+ Readonly<{
2116
+ id: "effect-retry-policy";
2117
+ introducedInModel: 10;
2118
+ minReaderModel: 10;
2119
+ documentTypes: readonly ["definition", "instance"];
2120
+ compatibility: "reader-floor";
2121
+ applicability: "detectable";
2122
+ summary: "An effect node declares a bounded retry policy the engine enforces on every runtime.";
2123
+ }>,
2017
2124
  ];
2018
2125
 
2019
2126
  /** The maximum reader floor this writer can emit for a detectable feature. */
2020
- export declare const DATA_MODEL_MAX_READER = 9;
2127
+ export declare const DATA_MODEL_MAX_READER = 10;
2021
2128
 
2022
2129
  /**
2023
2130
  * The unconditional model-4 reader floor for every engine-owned document.
@@ -2034,12 +2141,14 @@ export declare const DATA_MODEL_MIN_READER = 4;
2034
2141
  * instances are re-stamped on every full persist, so mixed-version fleets
2035
2142
  * honestly record whichever engine last shaped a doc.
2036
2143
  *
2037
- * Bump on every declared shape change (additive included). Bumping does NOT
2038
- * by itself lock out older engines that is the document's derived
2039
- * `minReaderModel` floor. Declare every bump in `DATAMODEL.md`; the model-surface snapshot test
2040
- * fails on undeclared drift.
2144
+ * A number is assigned per release, not per change: a declared shape change
2145
+ * merged before this model has shipped joins it, and one merged after it has
2146
+ * shipped moves the number on. Bumping does NOT by itself lock out older
2147
+ * engines that is the document's derived `minReaderModel` floor. Declare
2148
+ * every change in `DATAMODEL.md`; the model-surface snapshot test fails on
2149
+ * undeclared drift.
2041
2150
  */
2042
- export declare const DATA_MODEL_VERSION = 9;
2151
+ export declare const DATA_MODEL_VERSION = 10;
2043
2152
 
2044
2153
  export declare interface DataModelChange {
2045
2154
  readonly id: string;
@@ -2137,6 +2246,16 @@ export declare const DEFAULT_TRANSITION_WHEN = "$allActivitiesDone";
2137
2246
  */
2138
2247
  export declare const defaultLoggerFactory: LoggerFactory;
2139
2248
 
2249
+ /**
2250
+ * What `defineWorkflow` returns: the stored definition, plus `runtime` when the
2251
+ * workflow or one of its effects declared a hosting kind. Generation and the
2252
+ * blueprint tooling read `runtime`; the deploy drops it, so it never reaches the
2253
+ * Content Lake and never affects a definition's content fingerprint.
2254
+ */
2255
+ export declare type DefinedWorkflow = WorkflowDefinition & {
2256
+ runtime?: DefinitionRuntime | undefined;
2257
+ };
2258
+
2140
2259
  export declare interface DefinitionConditionSite {
2141
2260
  /** The stage the condition applies in; absent only for author predicates. */
2142
2261
  stage?: string;
@@ -2221,6 +2340,17 @@ export declare function definitionRoleNames(
2221
2340
  definition: WorkflowDefinition,
2222
2341
  ): readonly string[];
2223
2342
 
2343
+ /**
2344
+ * The hosting declarations {@link DefinedWorkflow} carries for the generator,
2345
+ * collected out of the authored tree. `kind` is present only when the workflow
2346
+ * declared one, so an absent `kind` inherits the deployment's. `effects` holds
2347
+ * one entry per effect that declared a block, keyed by effect name.
2348
+ */
2349
+ export declare interface DefinitionRuntime {
2350
+ kind?: RuntimeKind | undefined;
2351
+ effects?: Record<string, EffectRuntimeBlock> | undefined;
2352
+ }
2353
+
2224
2354
  export declare interface DefinitionsForDocumentArgs {
2225
2355
  /**
2226
2356
  * The LOADED candidate document — unlike {@link InstancesForDocumentArgs},
@@ -2608,6 +2738,8 @@ export declare type DiagnosedTransition = Pick<
2608
2738
  * builds it from a real {@link WorkflowEvaluation}.
2609
2739
  */
2610
2740
  export declare interface DiagnoseInput extends DocumentStuckInput {
2741
+ /** Missing references read by unmet requirements or transition conditions; omit when not checked. */
2742
+ missingDocuments?: MissingDocument[];
2611
2743
  instance: Pick<
2612
2744
  WorkflowInstance,
2613
2745
  | "currentStage"
@@ -2624,14 +2756,15 @@ export declare interface DiagnoseInput extends DocumentStuckInput {
2624
2756
  }
2625
2757
 
2626
2758
  /** Narrow a full {@link WorkflowEvaluation} to the {@link DiagnoseInput} the
2627
- * classifier reads. */
2759
+ * classifier reads. Throws when populated missing-reference evidence lacks
2760
+ * its blocking subset. */
2628
2761
  export declare function diagnoseInputFromEvaluation(
2629
2762
  evaluation: WorkflowEvaluation,
2630
2763
  ): DiagnoseInput;
2631
2764
 
2632
2765
  /**
2633
- * Classify an instance. Terminal states win first; then the genuine stuck
2634
- * causes (nothing advances on its own or via a normal action); then `waiting`
2766
+ * Classify an instance. Terminal states win first; then effect or activity
2767
+ * faults; then missing references read by unmet conditions; then transition faults; then `waiting`
2635
2768
  * (an action is available — healthy); then `blocked` (an active activity held by
2636
2769
  * an unmet requirement — healthy, not yet actionable); else `progressing` (a
2637
2770
  * transition is already satisfied and will cascade).
@@ -2785,12 +2918,10 @@ export declare type DisabledReason =
2785
2918
  }
2786
2919
  | {
2787
2920
  /**
2788
- * The activity's declared {@link Activity.requirements} aren't all satisfied
2789
- * the readiness axis. The activity is visible and the actor authorized, but
2790
- * its own preconditions don't hold yet. `unmetRequirements` carries the
2791
- * authored descriptors so a consumer can disable the affirmative control and say
2792
- * which precondition is outstanding. Distinct from `filter-failed`
2793
- * (visibility/authorization) and `mutation-guard-denied` (content-write).
2921
+ * An authored activity requirement is unmet, or a selected target of a
2922
+ * required reference field cannot be read. Use `unmetRequirements` to
2923
+ * explain what blocks the action. Required-reference descriptors use
2924
+ * `field:<name>`; they have no entry in `requirementInsights`.
2794
2925
  */
2795
2926
  kind: "requirements-unmet";
2796
2927
  unmetRequirements: RequirementDescriptor[];
@@ -2875,6 +3006,21 @@ export declare interface DocumentActionDenialsArgs {
2875
3006
  dereference?: GuardDereference;
2876
3007
  }
2877
3008
 
3009
+ /**
3010
+ * Completed evidence for a document absent from the snapshot. `deleted` confirms
3011
+ * absence across versions; `outside-perspective` identifies an existing representation.
3012
+ * `unreadable` covers denied access and unsuccessful availability checks.
3013
+ */
3014
+ export declare type DocumentAvailability =
3015
+ | "deleted"
3016
+ | "unreadable"
3017
+ | "outside-perspective";
3018
+
3019
+ /** Supplies completed availability evidence for references absent from an evaluation snapshot. */
3020
+ export declare type DocumentAvailabilityReader = (
3021
+ documents: readonly MissingDocument[],
3022
+ ) => Promise<ReadonlyMap<string, DocumentAvailability>>;
3023
+
2878
3024
  /** @inline */
2879
3025
  declare type DocumentEnvelopeKey =
2880
3026
  | `_${string}`
@@ -2898,8 +3044,8 @@ export declare function documentPrefilter(
2898
3044
 
2899
3045
  /**
2900
3046
  * Classify an instance from its document alone — no evaluation, no reads, no
2901
- * actor. The transition-level causes need GROQ `when` results, so only
2902
- * {@link diagnoseInstance} reaches those.
3047
+ * actor. Document absence and transition-level causes require an evaluation,
3048
+ * so only {@link diagnoseInstance} reaches those.
2903
3049
  *
2904
3050
  * Sound but incomplete, and a consumer must present it that way: `undefined`
2905
3051
  * means "no cause this classifier can see", never "healthy". Flag an instance on
@@ -2942,10 +3088,13 @@ export declare interface DrainEffectsResult {
2942
3088
  failed: PendingEffect[];
2943
3089
  skipped: PendingEffect[];
2944
3090
  /**
2945
- * Entries this drainer dispatched whose completion lost to another party
2946
- * (a lease-expiry takeover finishing first, or a manual recovery). The
2947
- * handler's side effect ran here too the at-least-once overlap the
2948
- * {@link EffectHandler} contract tells handlers to tolerate.
3091
+ * Entries this drainer dispatched without settling. Either another party
3092
+ * settled the entry first (a lease-expiry takeover, a manual recovery, or a
3093
+ * completion landing while a `retry` run waited out a backoff), or a `retry`
3094
+ * run stopped because the claim could no longer be held, which leaves the
3095
+ * entry pending for a later drain. The handler's side effect ran here too:
3096
+ * the at-least-once overlap the {@link EffectHandler} contract tells
3097
+ * handlers to tolerate.
2949
3098
  */
2950
3099
  lost: PendingEffect[];
2951
3100
  }
@@ -3137,20 +3286,24 @@ export declare interface EditFieldTarget {
3137
3286
  export declare type EditMode = "set" | "append" | "unset";
3138
3287
 
3139
3288
  /**
3140
- * A registered effect: `name` is its only identity (unique per definition,
3141
- * read downstream as `$effects.<name>`) the host app registers a handler
3142
- * against it 1:1, and the stored definition never references code.
3143
- * `bindings` are GROQ reads over the rendered scope, resolved to concrete
3144
- * JSON at queue time; `input` is static config passed through verbatim.
3145
- * `outputs` (typed {@link FieldShape}s) is a STRICT allowlist: at completion
3146
- * an undeclared output key, or a value that doesn't fit its shape, fails the
3147
- * completion and nothing is stored. Omitting `outputs` is an EMPTY allowlist,
3148
- * so ANY returned output is rejected and fails the completion — the bound is
3149
- * universal, not opt-in.
3289
+ * External work queued for the handler registered under `name`. Names are
3290
+ * unique within a definition; completed outputs are read as `$effects['<name>']`.
3291
+ *
3292
+ * `bindings` resolves GROQ expressions against the action's rendered scope
3293
+ * when the effect is queued. The handler receives one parameter bag combining
3294
+ * those values with static `input`. An `input` key overrides a same-named
3295
+ * binding, including when its value is null.
3296
+ *
3297
+ * `outputs` declares the allowed result keys and their {@link FieldShape}s.
3298
+ * An undeclared key or invalid value rejects the completion without storing
3299
+ * it. Omitting `outputs` allows no output keys.
3300
+ *
3301
+ * `retry` ({@link EffectRetry}) bounds how many times a failing handler is
3302
+ * attempted. Omitting it completes the effect as failed on the first failure.
3150
3303
  *
3151
3304
  * @interface
3152
3305
  */
3153
- export declare type Effect = v.InferOutput<typeof EffectSchema>;
3306
+ export declare type Effect = EffectFields<EffectRetry>;
3154
3307
 
3155
3308
  /** Total commits one dispatch may make — the runaway-handler bound: without
3156
3309
  * it, a looping reporter renews its own lease and appends history forever.
@@ -3188,6 +3341,17 @@ export declare type EffectCompletionStatus = Exclude<
3188
3341
  "cancelled"
3189
3342
  >;
3190
3343
 
3344
+ /** @inline */
3345
+ declare type EffectFields<TRetry> = {
3346
+ name: string;
3347
+ title?: string | undefined;
3348
+ description?: string | undefined;
3349
+ bindings?: Record<string, string> | undefined;
3350
+ input?: Record<string, unknown> | undefined;
3351
+ outputs?: FieldShape[] | undefined;
3352
+ retry?: TRetry | undefined;
3353
+ };
3354
+
3191
3355
  /**
3192
3356
  * External effect handler — invoked at drain time with resolved `params` and
3193
3357
  * a context. Returning `outputs` records them on the run's `effectHistory`
@@ -3195,15 +3359,29 @@ export declare type EffectCompletionStatus = Exclude<
3195
3359
  * applies the state half of the effect in the completion commit (`field.*`
3196
3360
  * only, never `status.set`) — every returned op must explicitly set
3197
3361
  * `target.scope`, since completion ops have no authoring location to infer
3198
- * one from. Throwing marks the effect failed, with no `ops`.
3362
+ * one from. Throwing fails the attempt, with no `ops`. Without a
3363
+ * {@link EffectRetry} policy on the node, or once one has spent its attempts
3364
+ * or closed its window, that failure settles the effect as failed. A policy
3365
+ * with attempts left inside its window dispatches again instead, unless the
3366
+ * drain finds between two attempts that it no longer holds the claim: then it
3367
+ * stops without settling and reports the entry as `lost`. That check happens
3368
+ * between attempts only. The completion itself stays first-writer-wins, so a
3369
+ * dispatch that runs to its end still reports its outcome and settles the
3370
+ * entry if it gets there first.
3199
3371
  *
3200
3372
  * Delivery is at-least-once: a handler MAY run more than once for the same
3201
- * effect (a dispatch dying after its side effect but before commit, or a
3202
- * lease expiring mid-dispatch and being taken over). Completion is
3203
- * first-writer-wins the losing run's completion is reported as `lost`.
3204
- * Write handlers to tolerate this: check `effectHistory[]` for a row keyed
3205
- * by `ctx.effectKey` before irreversible work, and derive external
3206
- * identifiers from `ctx.effectKey` so the receiving system can dedupe.
3373
+ * effect. Three causes. A dispatch can die after its side effect but before
3374
+ * commit. A lease can expire mid-dispatch and be taken over. And every
3375
+ * admitted attempt of a `retry` policy invokes the handler again. Completion
3376
+ * is first-writer-wins, and the losing run's completion is reported as `lost`.
3377
+ *
3378
+ * Write handlers to tolerate repetition. Derive external identifiers from
3379
+ * `ctx.effectKey` so the receiving system can dedupe: the key is stable across
3380
+ * every repeat, including all attempts of one policy run. Checking
3381
+ * `effectHistory[]` for a row keyed by `ctx.effectKey` before irreversible
3382
+ * work catches a repeat of an already-completed run, but never a retry
3383
+ * attempt, because a policy writes one history row when the whole run ends and
3384
+ * nothing records the attempt that just failed.
3207
3385
  *
3208
3386
  * The `bivarianceHack` indirection keeps this readable from the non-generic
3209
3387
  * `Engine` surface; only the typed drain invokes handlers.
@@ -3338,6 +3516,66 @@ export declare function effectOutputsMap(
3338
3516
  instance: Pick<WorkflowInstance, "effectHistory">,
3339
3517
  ): Record<string, unknown>;
3340
3518
 
3519
+ /**
3520
+ * A bounded retry policy for one effect. Both bounds govern one drain's run of
3521
+ * the policy, not the effect's lifetime: a drainer that dies mid-run leaves the
3522
+ * entry for the next drain, which starts a fresh run with the full budget, so
3523
+ * an effect can see more handler calls in total than `attempts`.
3524
+ *
3525
+ * `attempts` is the total number of attempts in a run, the first included, so
3526
+ * `1` means "never retry".
3527
+ *
3528
+ * `expiryMs` and the backoff a policy accumulates are each capped at 366 days
3529
+ * (`31_622_400_000` ms), inclusive. Deploy refuses a policy declaring more,
3530
+ * and one whose accumulated backoff reaches its own `expiryMs` before its
3531
+ * `attempts` are spent. Those checks weigh the declared waits alone. At
3532
+ * runtime every elapsed millisecond counts against `expiryMs`, handler time
3533
+ * included, so a slow handler can leave attempts unused. `backoff` paces
3534
+ * them; omitting it retries with no wait. Every duration is a whole number of
3535
+ * milliseconds above zero, and `attempts` a whole count above zero; deploy
3536
+ * rejects anything else.
3537
+ *
3538
+ * `expiryMs` decides whether a further attempt may start, measured from the
3539
+ * moment this run dispatched its first attempt. The window closes
3540
+ * on reaching it, so an attempt is admitted only while less than `expiryMs`
3541
+ * has elapsed. It is not a handler timeout. An attempt already running is
3542
+ * never interrupted, so a run can finish after the window, and a success then
3543
+ * still counts. Omitting it leaves `attempts` as the only bound.
3544
+ *
3545
+ * A policy that runs out of attempts, or that `expiryMs` stops, completes the
3546
+ * effect as failed, and `$effectStatus['<name>'] == 'failed'` routes the
3547
+ * instance. A successful attempt completes it as done, whichever attempt
3548
+ * succeeded. An effect with no `retry` completes as failed on its handler's
3549
+ * first failure.
3550
+ */
3551
+ export declare type EffectRetry = EffectRetryFields & {
3552
+ kind: EffectRetryKind;
3553
+ };
3554
+
3555
+ /**
3556
+ * How long the engine waits between two attempts. `delayMs` is that wait in
3557
+ * milliseconds: `'fixed'` waits it every time, `'exponential'` doubles it per
3558
+ * attempt already made (`delayMs`, then `2 × delayMs`, then `4 × delayMs`).
3559
+ */
3560
+ export declare type EffectRetryBackoff = {
3561
+ kind: "fixed" | "exponential";
3562
+ delayMs: number;
3563
+ };
3564
+
3565
+ /** @inline */
3566
+ declare type EffectRetryFields = {
3567
+ attempts: number;
3568
+ backoff?: EffectRetryBackoff | undefined;
3569
+ expiryMs?: number | undefined;
3570
+ };
3571
+
3572
+ /**
3573
+ * Who runs a retry policy. `'engine'` is the only member: the engine loops
3574
+ * inside the `drainEffects` call that picked the effect up, holding the claim
3575
+ * across the waits.
3576
+ */
3577
+ export declare type EffectRetryKind = "engine";
3578
+
3341
3579
  /**
3342
3580
  * Every terminal state an effect run can record. `done` and `failed` are
3343
3581
  * reported through completion ({@link EffectCompletionStatus}); `cancelled`
@@ -3347,43 +3585,25 @@ export declare function effectOutputsMap(
3347
3585
  */
3348
3586
  export declare type EffectRunStatus = "done" | "failed" | "cancelled";
3349
3587
 
3350
- declare const EffectSchema: v.StrictObjectSchema<
3351
- {
3352
- readonly name: v.SchemaWithPipe<
3353
- readonly [
3354
- v.StringSchema<undefined>,
3355
- v.MinLengthAction<string, 1, "must be a non-empty string">,
3356
- ]
3357
- >;
3358
- readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
3359
- readonly description: v.OptionalSchema<
3360
- v.StringSchema<undefined>,
3361
- undefined
3362
- >;
3363
- readonly bindings: v.OptionalSchema<
3364
- v.RecordSchema<
3365
- v.StringSchema<undefined>,
3366
- v.SchemaWithPipe<
3367
- readonly [
3368
- v.StringSchema<undefined>,
3369
- v.MinLengthAction<string, 1, "must be a non-empty string">,
3370
- ]
3371
- >,
3372
- undefined
3373
- >,
3374
- undefined
3375
- >;
3376
- readonly input: v.OptionalSchema<
3377
- v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>,
3378
- undefined
3379
- >;
3380
- readonly outputs: v.OptionalSchema<
3381
- v.ArraySchema<v.GenericSchema<FieldShape>, undefined>,
3382
- undefined
3383
- >;
3384
- },
3385
- undefined
3386
- >;
3588
+ /**
3589
+ * The `runtime` block on an effect node, overriding its workflow's kind.
3590
+ * `timeout` is seconds and `memory` megabytes of the function that runs this
3591
+ * handler, and an effect declaring either gets its own drain function instead of
3592
+ * sharing the deployment's. Both are the function budget, so both are accepted
3593
+ * only under `'function'`.
3594
+ */
3595
+ export declare type EffectRuntimeBlock =
3596
+ | {
3597
+ kind: "function";
3598
+ timeout?: number | undefined;
3599
+ memory?: number | undefined;
3600
+ }
3601
+ | {
3602
+ kind: "durableFunction";
3603
+ }
3604
+ | {
3605
+ kind: "selfHosted";
3606
+ };
3387
3607
 
3388
3608
  /** The `effectHistory` outcome {@link EffectNotFoundError} reports when the
3389
3609
  * missing key belongs to a settled run. `detail` is the row's recorded
@@ -3394,6 +3614,21 @@ export declare interface EffectSettledInfo {
3394
3614
  detail?: string;
3395
3615
  }
3396
3616
 
3617
+ /** One declared effect plus a structural location string identifying where it
3618
+ * sits in the definition (for diagnostics). */
3619
+ export declare interface EffectSite {
3620
+ effect: Effect;
3621
+ location: string;
3622
+ }
3623
+
3624
+ /**
3625
+ * Every effect a definition declares, with its location — the single source of
3626
+ * "where effects live": action `effects[]` (actions are the only payload
3627
+ * carriers). Effect names are unique per definition, so consumers can key by
3628
+ * `site.effect.name` cleanly.
3629
+ */
3630
+ export declare function effectSites(def: WorkflowDefinition): EffectSite[];
3631
+
3397
3632
  export declare interface Engine {
3398
3633
  /** Engine-scoped bindings — exposed for the few advanced consumers
3399
3634
  * (e.g. test bench, drain workers) that need them; the verbs already
@@ -3410,6 +3645,9 @@ export declare interface Engine {
3410
3645
  resolveActor: (
3411
3646
  args: ResolveClientActorArgs,
3412
3647
  ) => Promise<ActorResolution<ClientProjectUser>>;
3648
+ /** Validates and stores immutable definition versions. Content matching the
3649
+ * latest deployed version's fingerprint keeps that version; otherwise,
3650
+ * deployment creates the next version. Batch dependencies deploy children first. */
3413
3651
  deployDefinitions: <T extends WorkflowDefinitionInput<T>>(
3414
3652
  args: DeployDefinitionsArgs<T>,
3415
3653
  ) => Promise<DeployDefinitionsResult>;
@@ -3418,15 +3656,25 @@ export declare interface Engine {
3418
3656
  * starts without complaint. `instanceId` is the idempotency key: reusing
3419
3657
  * it for the same start resumes; a different start throws. */
3420
3658
  startInstance: (args: StartInstanceArgs) => Promise<OperationResult>;
3659
+ /** Commits a caller-fired action and runs the resulting cascade. Actions
3660
+ * declaring `when` cannot be fired through this method. Dispatch queued
3661
+ * effects separately with {@link Engine.drainEffects}. */
3421
3662
  fireAction: (args: FireActionArgs) => Promise<OperationResult>;
3422
3663
  /** Edit a declared-editable field directly (the generic edit seam):
3423
3664
  * reassign / reschedule / claim-by-hand / append-to-log, then cascade. */
3424
3665
  editField: (args: EditFieldArgs) => Promise<OperationResult>;
3666
+ /** Records an effect result, applies its completion field operations, and
3667
+ * runs the resulting cascade. Use {@link Engine.drainEffects} to invoke
3668
+ * registered handlers. */
3425
3669
  completeEffect: (args: CompleteEffectArgs) => Promise<OperationResult>;
3426
3670
  /** Commit mid-dispatch field state from a running effect handler — the
3427
3671
  * verb behind `ctx.commitOps`. Gated on the dispatch's exact claim token;
3428
3672
  * a successful commit renews the claim's lease. */
3429
3673
  commitEffectOps: (args: CommitEffectOpsArgs) => Promise<OperationResult>;
3674
+ /** Reevaluates an instance and commits enabled triggers and transitions
3675
+ * until progression settles. A successful call reports `changed: false`
3676
+ * when the instance remains unchanged. It does not run effect handlers;
3677
+ * dispatch queued work with {@link Engine.drainEffects}. */
3430
3678
  tick: (args: OperationArgs) => Promise<OperationResult>;
3431
3679
  /** Project the instance from an actor's perspective — per-action verdicts
3432
3680
  * with structured disabled reasons. Pure read. */
@@ -3441,8 +3689,9 @@ export declare interface Engine {
3441
3689
  setStage: (args: SetStageArgs) => Promise<OperationResult>;
3442
3690
  /** Admin override — hard-stop an in-flight instance where it stands. */
3443
3691
  abortInstance: (args: AbortInstanceArgs) => Promise<OperationResult>;
3444
- /** Admin override — reset a failed/terminal activity in the current stage
3445
- * back to `active` (re-run) or `skipped` (bypass), then cascade. */
3692
+ /** Changes a terminal activity in the current stage to `active` or `skipped`,
3693
+ * then continues the cascade. Already-fired triggers do not fire again
3694
+ * during the same stage visit. */
3446
3695
  resetActivity: (args: ResetActivityArgs) => Promise<OperationResult>;
3447
3696
  /** Admin override — remove a deployed definition (instances are only ever aborted, never deleted). */
3448
3697
  deleteDefinition: (
@@ -3683,11 +3932,13 @@ export declare interface EvaluateArgs {
3683
3932
  }
3684
3933
 
3685
3934
  /**
3686
- * The pure projection at the heart of runtime evaluation: given an
3687
- * instance, its definition, the resolved actor/grants, and a snapshot,
3688
- * compute "what can this actor do right now, and why not the rest." The
3935
+ * Evaluates an
3936
+ * instance, its definition, resolved actor/grants, and a snapshot to
3937
+ * report available actions and their blocking conditions. The
3689
3938
  * supplied snapshot is never refetched; guards using `->` may call the
3690
- * supplied {@link EvaluateFromSnapshotArgs.guardDereference} resolver.
3939
+ * supplied {@link EvaluateFromSnapshotArgs.guardDereference} resolver. An optional
3940
+ * {@link EvaluateFromSnapshotArgs.documentAvailability} reader supplies completed
3941
+ * evidence for missing references without replacing held content.
3691
3942
  * Feed it a fresh snapshot (e.g. rebuilt from a live store on change) for
3692
3943
  * reactive re-evaluation. Best-effort by design: verdicts are advisory,
3693
3944
  * not enforcement.
@@ -3722,10 +3973,13 @@ export declare interface EvaluateFromSnapshotArgs {
3722
3973
  /**
3723
3974
  * The in-memory snapshot to evaluate against. The caller assembles it
3724
3975
  * from whatever source — a fetch-backed evaluation or a
3725
- * live store. The `_id` of every doc must be in GDR-URI form, as
3726
- * {@link buildSnapshot} produces.
3976
+ * live store. Every doc's `_id` must be in GDR-URI form, and `knownIds`
3977
+ * must contain exactly those IDs for missing-reference diagnostics.
3978
+ * Use {@link buildSnapshot} to construct both consistently.
3727
3979
  */
3728
3980
  snapshot: HydratedSnapshot;
3981
+ /** Resolve availability outside the snapshot's perspective. Without a reader, absence is reported without claiming deletion. */
3982
+ documentAvailability?: DocumentAvailabilityReader;
3729
3983
  /**
3730
3984
  * The `$now` reading every condition in this projection shares. Omit to
3731
3985
  * use {@link wallClock}; a reactive consumer (or the bench) passes its
@@ -3950,11 +4204,7 @@ export declare function extractDocumentId(gdrUriString: string): string;
3950
4204
  /** `resourcePath` is caller-supplied so this works for both project ACLs and a dedicated workflow-collaboration resource. */
3951
4205
  declare function fetchGrants(args: {
3952
4206
  client: {
3953
- request: <T>(opts: {
3954
- url: string;
3955
- signal?: AbortSignal;
3956
- tag?: string;
3957
- }) => Promise<T>;
4207
+ request: NonNullable<WorkflowClient["request"]>;
3958
4208
  };
3959
4209
  resourcePath: string;
3960
4210
  signal?: AbortSignal;
@@ -4096,7 +4346,26 @@ export declare interface FieldDescription {
4096
4346
  }
4097
4347
 
4098
4348
  /**
4099
- * One declared field entry as authored and stored: name, value kind, and its scope's sourcing and editability.
4349
+ * A field declaration whose location determines its scope and lifetime.
4350
+ * Workflow fields initialize at start; stage and activity fields initialize
4351
+ * on each stage visit. {@link FieldSource} controls initialization;
4352
+ * {@link Editable} controls direct edits independently.
4353
+ *
4354
+ * `required: true` is valid only on workflow-scope fields with an `input`
4355
+ * source. It requires a non-null value at start or spawn. On `subject`,
4356
+ * `doc.ref`, and `doc.refs`, selected targets must also remain readable in the
4357
+ * workflow perspective after initialization. Missing targets block normal
4358
+ * actions, triggered actions, and transitions. Abort and permitted field edits remain available.
4359
+ * `subject` is also
4360
+ * workflow-scope-only, with at most one subject per definition. Each scope
4361
+ * may declare at most one `dueDate` or `dueDatetime` field, always top-level.
4362
+ *
4363
+ * `types` is a nonempty list of accepted document types on `subject`,
4364
+ * `doc.ref`, or `doc.refs`; omit it to accept any document type. `roles`
4365
+ * constrains assignment eligibility only on `assignee` and `assignees`.
4366
+ * {@link FieldShape}, {@link ChoiceOptions}, and {@link ScalarValidation}
4367
+ * define the nested-shape and scalar constraints. Authoring conveniences are
4368
+ * accepted by {@link AuthoringFieldEntry}.
4100
4369
  *
4101
4370
  * @interface
4102
4371
  */
@@ -4139,7 +4408,22 @@ export declare interface FieldInsight {
4139
4408
 
4140
4409
  export declare type FieldKind = keyof FieldValueMap;
4141
4410
 
4142
- /** A field mutation targeting the supplied field-reference shape. */
4411
+ /**
4412
+ * A field mutation targeting a declared field. Resolved values must satisfy
4413
+ * that field's shape, choices, validation, and assignment constraints.
4414
+ *
4415
+ * `field.setIfMissing` supports nullable fields only. If a value exists, it
4416
+ * leaves the value unchanged and records no `opApplied` history event.
4417
+ * `field.inc` and `field.dec` require an initialized `number` field; their
4418
+ * delta defaults to `1`. Both the delta and resulting value must be finite,
4419
+ * and the result must satisfy the field's validation bounds.
4420
+ *
4421
+ * `field.append` adds one valid list member. `field.updateWhere` accepts only
4422
+ * `array` fields and merges an object into matching rows. The merge cannot
4423
+ * write `_key` or `_type`, and each resulting row must satisfy its declared
4424
+ * shape. `field.removeWhere` supports list fields. See {@link Op} for row
4425
+ * selection and history behavior.
4426
+ */
4143
4427
  export declare type FieldMutationOp<
4144
4428
  TTarget extends {
4145
4429
  field: string;
@@ -4187,8 +4471,9 @@ export declare type FieldMutationOp<
4187
4471
  };
4188
4472
 
4189
4473
  /**
4190
- * A stored field mutation. `field.inc` and `field.dec` use the same names as
4191
- * `@sanity/client` patches and default an omitted `value` to a delta of `1`.
4474
+ * A {@link FieldMutationOp} whose target scope is explicit. Actions can write
4475
+ * fields in their activity, stage, or workflow. Effect completions accept only
4476
+ * workflow- or stage-scoped field operations, never activity status changes.
4192
4477
  */
4193
4478
  export declare type FieldOp = FieldMutationOp<StoredFieldRef>;
4194
4479
 
@@ -4220,12 +4505,16 @@ declare type FieldReadExpr = {
4220
4505
  export declare type FieldScope = "workflow" | "stage" | "activity";
4221
4506
 
4222
4507
  /**
4223
- * A sub-field shape used inside an `object`'s `fields` or an `array`'s `of`
4224
- * lighter than {@link FieldEntry}: no `initialValue`/`editable`/`required`,
4225
- * since a sub-field's value comes from the parent. An `object` kind requires
4226
- * non-empty `fields` and no `of`; an `array` kind requires non-empty `of` and
4227
- * no `fields`; every other kind requires neither enforced at parse, not
4228
- * visible in this type.
4508
+ * A nested field shape inside an object's `fields`, an array's `of`, or an
4509
+ * effect's `outputs`. It has no initialization, direct editability, or required
4510
+ * setting; those belong to {@link FieldEntry}.
4511
+ *
4512
+ * An `object` requires nonempty `fields` and no `of`. An `array` requires
4513
+ * nonempty `of` and no `fields`. Other types accept neither. Sibling names
4514
+ * must be unique. Use ordinary `date` and `datetime` here; `dueDate` and
4515
+ * `dueDatetime` are not valid nested fields or effect outputs.
4516
+ * {@link ChoiceOptions} and {@link ScalarValidation} constrain supported
4517
+ * scalar types. `roles` is valid only on `assignee` and `assignees` shapes.
4229
4518
  */
4230
4519
  export declare interface FieldShape {
4231
4520
  type: FieldValueKind;
@@ -4241,11 +4530,28 @@ export declare interface FieldShape {
4241
4530
  }
4242
4531
 
4243
4532
  /**
4244
- * How a field seeds its `initialValue`, once at materialisation (advisory
4245
- * after the field stays freely editable). Absent means working memory: the
4246
- * field starts empty and an op fills it later, spelled by omission rather
4247
- * than an arm. Distinct from {@link ValueExpr}, an op's write payload; they
4248
- * overlap only on the literal and field-read arms.
4533
+ * Supplies a field's `initialValue` once, when the field is initialized.
4534
+ * Omitting the source starts the field empty; an operation can fill it later.
4535
+ * The source does not grant permission to edit. Direct editing requires an
4536
+ * {@link Editable | editable} declaration.
4537
+ *
4538
+ * Distinct from {@link ValueExpr}, which supplies an operation's write value.
4539
+ * Only the literal and field-read forms are shared.
4540
+ *
4541
+ * `input` reads workflow inputs supplied at start or spawn. Stage and activity
4542
+ * input seeds receive no caller value; activity input seeds produce a deploy
4543
+ * warning. `literal` supplies a fixed value. `query` runs against the Content
4544
+ * Lake with earlier fields in the same scope available as `$fields`.
4545
+ * Reference normalization can omit unrecognized values without recording
4546
+ * `fieldQueryDiscarded`. A result that fails validation after normalization
4547
+ * uses the field's empty value (`null` or `[]`) and records that event.
4548
+ * A failed query throws.
4549
+ *
4550
+ * A `fieldRead` seed reads earlier fields in its own scope when `scope` is
4551
+ * omitted. A stage or activity seed can read workflow fields with
4552
+ * `scope: 'workflow'`. An activity seed cannot read stage fields. At workflow
4553
+ * scope, omit `scope` to read an earlier workflow field. `path` selects a
4554
+ * nested value; these reads do not load referenced documents.
4249
4555
  */
4250
4556
  export declare type FieldSource = FieldSourceInternal;
4251
4557
 
@@ -4261,6 +4567,11 @@ declare type FieldSourceInternal =
4261
4567
  | LiteralExpr
4262
4568
  | FieldReadExpr;
4263
4569
 
4570
+ /** Shared diagnostic field-address label for workspace consumers; unsupported outside this workspace.
4571
+ * @internal
4572
+ */
4573
+ export declare function _fieldTargetLabel(target: EditFieldTarget): string;
4574
+
4264
4575
  /**
4265
4576
  * Every leaf replaced by its type name (`null` distinct from `object`); keys sorted by
4266
4577
  * UTF-16 code unit, not locale collation, so the shape canonicalises identically on every
@@ -4418,16 +4729,19 @@ export declare interface FiringConsequence {
4418
4729
  export { formatRead };
4419
4730
 
4420
4731
  /**
4421
- * Build a GDR URI from a workflow resource config + a document id
4422
- * within that resource. This is how the engine mints `_id`s for
4423
- * definitions / instances / ancestor refs into its own resource.
4732
+ * Creates a {@link GdrUri} for a document in the supplied resource. Dataset
4733
+ * document IDs must be stable; `drafts.` and `versions.<release>.` prefixes
4734
+ * throw. Select draft or release content through {@link WorkflowInstance.perspective}.
4424
4735
  */
4425
4736
  export declare function gdrFromResource(
4426
4737
  res: WorkflowResource,
4427
4738
  documentId: string,
4428
4739
  ): GdrUri;
4429
4740
 
4430
- /** Build a GDR (id + type) pointing at a document within a workflow resource. */
4741
+ /**
4742
+ * Creates a typed document reference in the supplied resource. Dataset
4743
+ * references require a stable document ID, as described by {@link gdrFromResource}.
4744
+ */
4431
4745
  export declare function gdrRef<TType extends string = string>({
4432
4746
  res,
4433
4747
  documentId,
@@ -4463,18 +4777,21 @@ export declare type GdrScheme =
4463
4777
  | "dashboard";
4464
4778
 
4465
4779
  /**
4466
- * Typed GDR URI string. The compiler rejects bare doc ids (`"doc-1"`)
4467
- * only `<scheme>:<...id-parts>` values typecheck. Construct one via
4468
- * `gdrUri()` / `gdrFromResource()` / `refDataset()` etc., or by hand
4469
- * with the scheme prefix baked in (`` `dataset:proj:ds:${docId}` `` ).
4780
+ * Resource-qualified document URI with a {@link GdrScheme} prefix. Construct
4781
+ * it with {@link gdrUri}, {@link gdrFromResource}, or {@link refDataset}.
4782
+ * Use {@link parseGdr} to validate a string's complete addressing format.
4470
4783
  *
4471
- * Combined with schema validation at the API boundary, this is the
4472
- * type + runtime guarantee that no bare-string id reaches the
4473
- * snapshot, field entry, or filter layer.
4784
+ * Dataset URIs require the stable document ID, such as `article-1`, without
4785
+ * a `drafts.` or `versions.<release>.` prefix. Select draft and release
4786
+ * content through {@link WorkflowInstance.perspective}.
4474
4787
  */
4475
4788
  export declare type GdrUri = `${GdrScheme}:${string}`;
4476
4789
 
4477
- /** Compose a GDR URI from parts. Inverse of `parseGdr`. */
4790
+ /**
4791
+ * Creates a {@link GdrUri} from addressing parts. For datasets, `documentId`
4792
+ * must be the stable ID; `drafts.` and `versions.<release>.` prefixes throw.
4793
+ * Select draft or release content through {@link WorkflowInstance.perspective}.
4794
+ */
4478
4795
  export declare function gdrUri(
4479
4796
  parts:
4480
4797
  | {
@@ -4559,8 +4876,13 @@ declare function grantsPermissionOn(args: {
4559
4876
  userId?: string;
4560
4877
  }): Promise<boolean>;
4561
4878
 
4562
- /** A named readiness condition. Activities accept only `'groq'`; workflow
4563
- * `start.requirements` also accepts `'singleSubject'` see {@link StartRequirement}. */
4879
+ /**
4880
+ * A named GROQ readiness condition. Its name must be unique in the containing
4881
+ * requirements array. Activity requirements use instance and caller variables;
4882
+ * workflow requirements use the input and projected dataset in {@link StartBlock}.
4883
+ * Every requirement must pass before the corresponding caller action or fresh
4884
+ * standalone start can commit.
4885
+ */
4564
4886
  export declare type GroqRequirement = RequirementBase & {
4565
4887
  type: "groq";
4566
4888
  query: string;
@@ -4700,7 +5022,10 @@ export declare type GuardDereference = (ref: {
4700
5022
  _ref: string;
4701
5023
  }) => PromiseLike<Record<string, unknown> | null>;
4702
5024
 
4703
- /** The stored document, pattern, type, and authored-action facets a guard matches. */
5025
+ /**
5026
+ * A stored guard's match criteria. See {@link AuthoringGuard} for matching
5027
+ * rules; stored `idRefs` contains strings instead of typed {@link GuardRead}s.
5028
+ */
4704
5029
  export declare type GuardMatch = Guard["match"];
4705
5030
 
4706
5031
  /**
@@ -4721,15 +5046,13 @@ export declare function guardMatches({
4721
5046
  }): boolean;
4722
5047
 
4723
5048
  /**
4724
- * A deploy-time value read on a guard's `match.idRefs` / `metadata`, typed
4725
- * like {@link ValueExpr} (`self`/`now`/`fieldRead`, plus the guard-only
4726
- * `effectsRead` for a completed effect's output). Workflow-scope only a
4727
- * guard outlives any activity, so `fieldRead` here carries no `scope`.
4728
- * Desugar prints the STORED string spelling the deploy resolver and guard
4729
- * refresh parse (`"$self"`, `"$now"`, `"$fields.<name>[.path]"`,
4730
- * `"$effects['<name>'][.path]"`); those spellings are single-line strings
4731
- * matched by anchored regexes, so a line break in a path would print an
4732
- * unparseable read.
5049
+ * A value read for a guard's `match.idRefs` or `metadata`, resolved when the
5050
+ * guard is created or refreshed. `fieldRead` reads workflow fields only;
5051
+ * stage and activity fields are unavailable. `effectsRead` reads a completed
5052
+ * effect's output. `self` supplies the instance's GDR URI and `now` its ISO
5053
+ * clock value.
5054
+ * Paths cannot contain line breaks, and effect names cannot contain `'`.
5055
+ * Stored {@link Guard} declarations carry string forms of these reads.
4733
5056
  */
4734
5057
  export declare type GuardRead =
4735
5058
  | {
@@ -4873,15 +5196,13 @@ export declare function guardsForResource(
4873
5196
  export { guillemets };
4874
5197
 
4875
5198
  /**
4876
- * Content fingerprint of an authored definition: the canonical JSON of its
4877
- * content, hashed. Stamped on the deployed document ({@link DeployedDefinition})
4878
- * and pinned on every instance, so a redeploy of identical content is a no-op
4879
- * and a definition that drifted from what an instance pinned is detectable.
4880
- *
4881
- * Advisory, like every engine check (the lake is the only enforcement point):
4882
- * FNV-1a is a fast, deterministic, dependency-free, isomorphic digest — enough
4883
- * to detect honest change and drift, not a tamper-proof seal. Kept synchronous
4884
- * so the pure planning path needs no `await`.
5199
+ * Computes a deterministic, non-cryptographic fingerprint of authored
5200
+ * definition content. The result is 16 lowercase hexadecimal characters.
5201
+ * Object-key order does not affect it; array order and field values do.
5202
+ * Pass authored content without stored-document envelope fields: this
5203
+ * function strips none of them. The authoring-only `runtime` block is the one
5204
+ * key it ignores, so two definitions that differ only in a hosting kind
5205
+ * fingerprint identically.
4885
5206
  */
4886
5207
  export declare function hashDefinitionContent(def: WorkflowDefinition): string;
4887
5208
 
@@ -5143,7 +5464,7 @@ export { humanize };
5143
5464
  export declare interface HydratedSnapshot {
5144
5465
  /** Hydrated docs, keyed by GDR URI as `_id`. */
5145
5466
  docs: SanityDocument[];
5146
- /** Existence-check helper; the core eval pipeline itself doesn't read it. */
5467
+ /** The GDR URIs of every document in `docs`, used to diagnose missing references. */
5147
5468
  knownIds: Set<string>;
5148
5469
  }
5149
5470
 
@@ -5391,7 +5712,8 @@ export declare interface InstanceSession {
5391
5712
  * call resolves the caller's identity/grants from the client's token over
5392
5713
  * the network (cached per client) — plus each foreign subject resource's
5393
5714
  * grants through its own client, for the subject-write forecast. The held
5394
- * snapshot is not refetched; a guard predicate using `->` reads its target
5715
+ * snapshot is not refetched. Missing references receive completed availability
5716
+ * metadata checks; a guard predicate using `->` reads its target
5395
5717
  * through the bound engine client. */
5396
5718
  evaluate(): Promise<WorkflowEvaluation>;
5397
5719
  /** Advance the instance against the held content: cascade auto-transitions,
@@ -5886,6 +6208,29 @@ export { MAX_COUNTERFACTUAL_INDEX };
5886
6208
  */
5887
6209
  export declare function minReaderModelOf(doc: object): number;
5888
6210
 
6211
+ /**
6212
+ * A selected document absent from the evaluated snapshot. Absence alone does
6213
+ * not prove deletion. When present, `availability` carries the completed check.
6214
+ * This evidence is derived for the evaluation and is never persisted.
6215
+ */
6216
+ export declare interface MissingDocument {
6217
+ target: EditFieldTarget;
6218
+ reference: GlobalDocumentReference;
6219
+ /** The declared field title, when available. */
6220
+ title?: string;
6221
+ /** Completed availability evidence. Failed or unsupported checks yield `unreadable`.
6222
+ * Omitted when the caller supplied only a content snapshot. */
6223
+ availability?: DocumentAvailability;
6224
+ }
6225
+
6226
+ /**
6227
+ * Shared formatter for Workflows integrations; not a supported consumer API.
6228
+ * @internal
6229
+ */
6230
+ export declare function _missingDocumentsSummary(
6231
+ documents: readonly MissingDocument[],
6232
+ ): string;
6233
+
5889
6234
  export declare interface MissingHandlerDeployInfo {
5890
6235
  phase: "deploy";
5891
6236
  name: string;
@@ -6131,8 +6476,15 @@ declare type NotesField = FieldBase<AuthoringEditable, GroupMembership> & {
6131
6476
  type: "notes";
6132
6477
  };
6133
6478
 
6134
- /** A `field.updateWhere` / `field.removeWhere` op's `where` selects rows to
6135
- * mutate with rendered-scope GROQ (`$row`, `$params` bound) row selection, not a gate; an unevaluable row never matches. */
6479
+ /**
6480
+ * An action operation: a {@link FieldOp} or a status change on an activity in
6481
+ * the current stage.
6482
+ *
6483
+ * For `field.updateWhere` and `field.removeWhere`, `where` evaluates each row
6484
+ * as `$row`. Caller-fired actions also supply `$params`. Referenced document
6485
+ * content is not loaded for row selection, and an unevaluable row never
6486
+ * matches. An operation matching no rows still records `opApplied` history.
6487
+ */
6136
6488
  export declare type Op =
6137
6489
  | FieldOp
6138
6490
  | {
@@ -6231,11 +6583,15 @@ export declare interface OperationResult {
6231
6583
  * audit. */
6232
6584
  ranOps?: OpAppliedSummary[];
6233
6585
  /**
6234
- * The nearest future instant (ISO 8601) at which the clock alone changes what
6235
- * the instance evaluates to; schedule the next `tick` for it. Derived per
6236
- * call, never persisted. Absent on a terminal instance, when no site yields a
6237
- * boundary from the instance's values, and for a gate reading `$now` beside a
6238
- * caller variable, which {@link WorkflowEvaluation.nextEvaluationAt} carries.
6586
+ * The earliest future ISO 8601 instant the engine can derive for a time-based
6587
+ * change to the instance's evaluation. Schedule the next {@link Engine.tick | tick} for it.
6588
+ * Excludes gates reading `$now` beside a caller variable;
6589
+ * {@link WorkflowEvaluation.nextEvaluationAt} carries those boundaries.
6590
+ * Derived per call, never persisted.
6591
+ *
6592
+ * Absent on a terminal instance or when the engine cannot derive a boundary.
6593
+ * Conditions using date arithmetic may yield no boundary. Time can still
6594
+ * affect a nonterminal instance when this value is absent.
6239
6595
  */
6240
6596
  nextEvaluationAt?: string;
6241
6597
  }
@@ -6253,10 +6609,11 @@ export declare function parentRef(
6253
6609
  /**
6254
6610
  * Parse one incoming definition at the deploy/diff boundary (`caller` prefixes
6255
6611
  * the error). Accepts authored content or a fetched definition document — the
6256
- * document envelope is stripped (the inverse of the deploy serialisation, so a
6257
- * fetched document round-trips to `unchanged` instead of fingerprinting its
6258
- * envelope as content), then the remainder strict-parses against the stored
6259
- * schema: any unknown key anywhere in the tree fails loud.
6612
+ * document envelope and the authoring-only `runtime` block are stripped (the
6613
+ * inverse of the deploy serialisation, so a fetched document round-trips to
6614
+ * `unchanged` instead of fingerprinting its envelope as content, and a hosting
6615
+ * kind never changes a definition's version), then the remainder strict-parses
6616
+ * against the stored schema: any unknown key anywhere in the tree fails loud.
6260
6617
  */
6261
6618
  export declare function parseDefinitionInput(
6262
6619
  def: Record<string, unknown>,
@@ -6291,8 +6648,10 @@ export declare interface ParsedGdr {
6291
6648
  }
6292
6649
 
6293
6650
  /**
6294
- * Parse a GDR URI into its scheme + addressing parts. Throws on
6295
- * unknown scheme or malformed shape.
6651
+ * Parses a GDR URI into its scheme and addressing parts. Throws for an
6652
+ * unknown scheme, malformed addressing, or a dataset document ID prefixed
6653
+ * with `drafts.` or `versions.<release>.`. Use the stable document ID and
6654
+ * select draft or release content through {@link WorkflowInstance.perspective}.
6296
6655
  */
6297
6656
  export declare function parseGdr(uri: string): ParsedGdr;
6298
6657
 
@@ -6575,8 +6934,8 @@ export declare class ReaderModelAcknowledgementError extends WorkflowError<"read
6575
6934
  readonly expectedMinReaderModel: unknown;
6576
6935
  readonly requiredMinReaderModel: number;
6577
6936
  readonly engineMinReaderModel = 4;
6578
- readonly engineMaxReaderModel = 9;
6579
- readonly engineModelVersion = 9;
6937
+ readonly engineMaxReaderModel = 10;
6938
+ readonly engineModelVersion = 10;
6580
6939
  readonly documentationUrl = "https://www.sanity.io/docs/workflows/prerelease";
6581
6940
  constructor(
6582
6941
  expectedMinReaderModel: unknown,
@@ -6632,7 +6991,11 @@ export declare function refDashboard<TType extends string = string>({
6632
6991
  type,
6633
6992
  }: ResourceRefArgs<TType>): GlobalDocumentReference<TType>;
6634
6993
 
6635
- /** Make a GDR pointer to a project-dataset doc. */
6994
+ /**
6995
+ * Creates a typed reference to a dataset document. Pass the stable document
6996
+ * ID; `drafts.` and `versions.<release>.` prefixes throw. Select draft or
6997
+ * release content through {@link WorkflowInstance.perspective}.
6998
+ */
6636
6999
  export declare function refDataset<TType extends string = string>({
6637
7000
  projectId,
6638
7001
  dataset,
@@ -6752,6 +7115,12 @@ export declare type RemediationVerb =
6752
7115
  | "set-stage"
6753
7116
  | "abort";
6754
7117
 
7118
+ /** @internal Validated project-member reads shared by workspace adapters; not a supported consumer API. */
7119
+ export declare function _requestProjectMembers(
7120
+ request: (options: { url: string }) => Promise<unknown>,
7121
+ projectId: string,
7122
+ ): Promise<_ClientProjectMember[]>;
7123
+
6755
7124
  /** The reader model a deployment must acknowledge for its submitted definitions. */
6756
7125
  export declare function requiredDefinitionReaderModel(
6757
7126
  definitions: readonly unknown[],
@@ -6798,7 +7167,10 @@ declare type RequirementBase = {
6798
7167
  description?: string | undefined;
6799
7168
  };
6800
7169
 
6801
- /** Authored identity and display copy for one readiness requirement. */
7170
+ /**
7171
+ * Identity and display copy for an unmet requirement. Authored requirements use
7172
+ * their declared names; required-reference readability checks use `field:<name>`.
7173
+ */
6802
7174
  export declare interface RequirementDescriptor {
6803
7175
  name: string;
6804
7176
  title?: string | undefined;
@@ -6817,11 +7189,10 @@ export declare interface ResetActivityArgs extends DedupableOperationArgs {
6817
7189
  /** Name of the activity to reset, within the instance's current stage. */
6818
7190
  activity: string;
6819
7191
  /**
6820
- * What to reset it into. `active` (the default) re-runs the activity — back
6821
- * in progress, for a caller to drive to completion again; `skipped` bypasses
6822
- * it terminal but resolved, so a `$allActivitiesDone`-gated exit transition
6823
- * can fire. `done` is intentionally not offered: a reset is recovery, not a
6824
- * silent success.
7192
+ * The target status. `active` (the default) reopens the activity for
7193
+ * caller-fired actions. `skipped` counts the activity as resolved for
7194
+ * `$allActivitiesDone`. Returning to `active` does not repeat a `when`
7195
+ * action that already fired during this stage visit.
6825
7196
  */
6826
7197
  to?: ResetActivityTarget;
6827
7198
  }
@@ -6952,9 +7323,22 @@ export declare function resolveFieldEntry(
6952
7323
  ): ResolvedFieldEntry | undefined;
6953
7324
 
6954
7325
  /**
6955
- * Resolve advisory `$attributes` for the caller-bound projection — project →
6956
- * org global-host attributes page. Cached per (client, orgId). Expected
6957
- * absences (401–404) leave the bag unbound; unexpected failures throw.
7326
+ * Resolves telemetry build or execution mode from `NODE_ENV`.
7327
+ * `production` stays `production`; `development` and `test` map to `development`.
7328
+ * Other values use the required fallback: CLI and MCP pass `production`, SDK
7329
+ * passes `development`. This does not identify the target deployment or dataset.
7330
+ * Unsupported outside the Workflows packages.
7331
+ * @internal
7332
+ */
7333
+ export declare function _resolveTelemetryEnvironment(
7334
+ nodeEnv: string | undefined,
7335
+ fallback: "development" | "production",
7336
+ ): "development" | "production";
7337
+
7338
+ /**
7339
+ * Resolve the caller's advisory `$attributes`. Results are cached per client
7340
+ * and organization. Expected absences (401–404) leave attributes undefined;
7341
+ * unexpected failures throw.
6958
7342
  * Call only from soft-gate paths (evaluate / fireAction filter re-check /
6959
7343
  * editField), never from ticks or drainers.
6960
7344
  */
@@ -7053,14 +7437,44 @@ export declare function retractStageGuards(args: StageGuardArgs): Promise<void>;
7053
7437
  */
7054
7438
  export declare type RoleAliases = Record<string, string[]>;
7055
7439
 
7440
+ /**
7441
+ * The `runtime` block on a deployment and on `defineWorkflow`. A workflow that
7442
+ * declares none inherits its deployment's kind, and a deployment that declares
7443
+ * none hosts on `'function'`. Authoring-only: the deploy strips it and stores
7444
+ * nothing.
7445
+ *
7446
+ * It is a hint to the generator and to callers, never a rule the engine
7447
+ * enforces. The engine never sees it: any engine built anywhere with a handler
7448
+ * for an effect drains that effect when it calls `drainEffects`, whatever kind
7449
+ * the node declares, so a `'selfHosted'` effect is drained by whoever registers
7450
+ * its handler, the Studio included.
7451
+ */
7452
+ export declare interface RuntimeBlock {
7453
+ kind: RuntimeKind;
7454
+ }
7455
+
7456
+ /**
7457
+ * Where the generated unattended runtime hosts a workflow or an effect.
7458
+ * `'function'` is a plain Sanity Function, `'durableFunction'` a durable one,
7459
+ * and `'selfHosted'` a process you run yourself.
7460
+ */
7461
+ export declare type RuntimeKind = "function" | "durableFunction" | "selfHosted";
7462
+
7056
7463
  /** Whether two workflow resources address the same place. */
7057
7464
  export declare function sameResource(
7058
7465
  a: WorkflowResource,
7059
7466
  b: WorkflowResource,
7060
7467
  ): boolean;
7061
7468
 
7062
- /** Inclusive scalar bounds. String/text bounds measure character length;
7063
- * number bounds measure the numeric value. */
7469
+ /**
7470
+ * Inclusive bounds for `string`, `text`, `number`, or `progress` values.
7471
+ * String/text bounds count characters and must be non-negative integers.
7472
+ * Number bounds are finite numeric values. Progress bounds may only narrow
7473
+ * its inclusive 0–100 range.
7474
+ *
7475
+ * Supply at least one bound. When both are present, `min` must not exceed
7476
+ * `max`. Null values remain allowed unless an input is required separately.
7477
+ */
7064
7478
  export declare interface ScalarValidation {
7065
7479
  min?: number | undefined;
7066
7480
  max?: number | undefined;
@@ -7136,6 +7550,13 @@ export declare type SignalSemantic = (typeof SIGNAL_SEMANTICS)[number];
7136
7550
  */
7137
7551
  export declare const silentLogger: EngineLogger;
7138
7552
 
7553
+ /**
7554
+ * A start requirement that rejects a fresh start when an unfinished run of
7555
+ * this definition holds the same subject, across deployed versions.
7556
+ * The workflow must declare an input-sourced `subject` field. Names are unique
7557
+ * within the requirements array. Like other engine checks, this is advisory;
7558
+ * it is not Content Lake enforcement.
7559
+ */
7139
7560
  export declare type SingleSubjectRequirement = RequirementBase & {
7140
7561
  type: "singleSubject";
7141
7562
  };
@@ -7171,6 +7592,18 @@ export declare interface SiteConsequence {
7171
7592
  after: ConditionOutcome;
7172
7593
  }
7173
7594
 
7595
+ /**
7596
+ * Suspends for `ms` before resolving. The engine's only deliberate wait is a
7597
+ * `retry` policy's backoff between attempts inside one `drainEffects` call, so
7598
+ * a deterministic harness substitutes one that moves its {@link Clock} instead
7599
+ * of spending real time. Injected once beside the clock, never per call.
7600
+ *
7601
+ * A substitute must not resolve before `ms` has passed on whatever clock the
7602
+ * engine reads: a policy's pacing and its `expiryMs` window are both judged
7603
+ * against that clock.
7604
+ */
7605
+ export declare type Sleeper = (ms: number) => Promise<void>;
7606
+
7174
7607
  /** Pure resource-local dereferencing for held snapshot evaluation. */
7175
7608
  export declare function snapshotGuardDereference(args: {
7176
7609
  snapshot: HydratedSnapshot;
@@ -7199,16 +7632,16 @@ export declare class SpawnContractsInvalidError extends WorkflowError<"spawn-con
7199
7632
  }
7200
7633
 
7201
7634
  /**
7202
- * A pure container — name, fields, guards, activities, transitions, no
7203
- * behaviour of its own. Activities own enter, transitions own exit and
7204
- * arrival; a stage with no transitions IS terminal (structural, nothing to
7205
- * declare or mis-declare). `guards` are lake mutation guards active while
7206
- * the stage holds, each compiling to a persisted guard document deployed on
7207
- * stage entry and retracted on exit. `editable` is a tighten-only override
7208
- * for the time the stage holds, keyed by an in-scope field name: the field's
7209
- * own `editable` is the ceiling, ANDed with the stage value at runtime, so an
7210
- * override can only NARROW never open a field the baseline left closed. An
7211
- * unlisted field inherits its baseline.
7635
+ * The fields, activities, guards, and outgoing routes for one stage visit.
7636
+ * A stage with no transitions is terminal: entering it completes the instance,
7637
+ * and it cannot declare activities. Put completion work in the source stage
7638
+ * or give the working stage an outgoing transition.
7639
+ *
7640
+ * Guards are registered on entry and retracted on exit. `editable` overrides
7641
+ * are keyed by in-scope field name and apply while the stage is current.
7642
+ * Each combines with the field's own edit condition using AND, so an override
7643
+ * can restrict editing but cannot open a field whose baseline is closed.
7644
+ * An unlisted field inherits its baseline.
7212
7645
  *
7213
7646
  * @interface
7214
7647
  */
@@ -7348,17 +7781,24 @@ export declare const START_REQUIREMENT_VARS: readonly {
7348
7781
  }[];
7349
7782
 
7350
7783
  /**
7351
- * How standalone runs of this workflow begin. `filter` is a READ-SIDE
7352
- * visibility predicate "should a start surface offer this workflow for
7353
- * this document?" evaluated by `definitionsForDocument`/applicability in
7354
- * the browse-time-pure start-filter context (`$tag`/`$definition`/`$now`
7355
- * bound; `$fields` cannot exist before inputs do, so a `$fields` read here
7356
- * is deploy-rejected). It is NOT a `startInstance` gate; the verb never
7357
- * reads it. `requirements` are named readiness checks evaluated in author
7358
- * order in the start-time context (GROQ nodes add `$fields`; `singleSubject`
7359
- * is the one-in-flight-run-per-subject rule) every node must pass before
7360
- * `startInstance` commits. Both are advisory like every engine-side check;
7361
- * the Content Lake remains the only enforcement point.
7784
+ * Discovery and readiness rules for standalone starts.
7785
+ * `filter` evaluates against a candidate document with `$tag`, `$definition`,
7786
+ * and `$now`. It controls discovery and never gates `startInstance`.
7787
+ * It cannot read `$fields` or caller variables.
7788
+ *
7789
+ * `requirements` evaluates named checks in declaration order before a fresh
7790
+ * standalone start. All must pass. Resuming an existing start and spawning
7791
+ * children do not rerun these checks. A GROQ requirement binds `$tag`,
7792
+ * `$definition`, `$now`, and `$fields`, with no candidate document root.
7793
+ * `$fields` contains supplied input values, including GDR reference envelopes;
7794
+ * it excludes computed defaults and hydrated document content.
7795
+ *
7796
+ * At both sites, `*` scans projected instances in the engine's tag. Each row
7797
+ * contains only `definition` (name), `subject` (GDR URI or null), and
7798
+ * `completedAt` (ISO timestamp or null). Completed and aborted runs are
7799
+ * included. Raw fields such as `_type`, `tag`, and `fields` are unavailable.
7800
+ * Use {@link SingleSubjectRequirement} for one unfinished run per subject.
7801
+ * These checks are advisory; the Content Lake remains the enforcement point.
7362
7802
  */
7363
7803
  export declare type StartBlock = StartFields & {
7364
7804
  kind: StartKind;
@@ -7464,15 +7904,19 @@ export declare interface StartInstanceArgs {
7464
7904
  initialFields?: InitialFieldValue[];
7465
7905
  ancestors?: GlobalDocumentReference[];
7466
7906
  /**
7467
- * The instance's start seed stable named values set once at start (or
7468
- * handed down by a parent's `spawn.context`) and never mutated after.
7907
+ * Stable named values supplied when starting this instance. They cannot
7908
+ * be changed after start.
7469
7909
  * Effect bindings and conditions read them as `$context.<name>`; the
7470
7910
  * `$effects` bag is separate (completed effects' outputs only).
7471
7911
  *
7472
- * Each value may be any JSON a scalar, a {@link GlobalDocumentReference},
7912
+ * Values supplied directly to start may be any JSON: a scalar,
7913
+ * a {@link GlobalDocumentReference},
7473
7914
  * or an arbitrary object/array. Scalars and GDRs store as their typed
7474
7915
  * `context` entries; anything else stores as one `context.json`
7475
7916
  * entry, so all forms read back the same under `$context.<name>`.
7917
+ * A parent's `spawn.context` has a narrower contract: only strings, numbers,
7918
+ * booleans, and full GDRs are accepted; nullish results are omitted, and
7919
+ * other objects or arrays reject the spawn.
7476
7920
  */
7477
7921
  context?: StartContext;
7478
7922
  /**
@@ -7498,15 +7942,22 @@ export declare interface StartInstanceArgs {
7498
7942
  */
7499
7943
  grantsFromPath?: string;
7500
7944
  /**
7501
- * Optional read-side perspective for this instance. Threaded into
7502
- * field-entry query resolution and spawn `forEach.groq` discovery so
7503
- * a workflow can scope its reads to a Content Release stack. Child
7504
- * instances inherit the parent's perspective on spawn.
7945
+ * Perspective for content reads, including field queries and subworkflow
7946
+ * discovery. An explicit value applies to workflow-field initialization
7947
+ * and subsequent reads.
7948
+ *
7949
+ * When omitted, workflow-field queries at start use `drafts`. After those
7950
+ * fields resolve, the instance uses `[releaseName]` from its first populated
7951
+ * workflow `release.ref` field, or `drafts` when none is populated.
7952
+ * Under `drafts`, drafts take precedence over published content.
7505
7953
  *
7506
- * Pass `[releaseName]` for a workflow whose subject is a release;
7507
- * pass `[releaseName, "drafts"]` to also include drafts; omit for
7508
- * the engine's default (no perspective override = `"raw"` on the
7509
- * test client).
7954
+ * A child's workflow fields initialize under its parent's perspective.
7955
+ * Afterward, the child's first populated workflow `release.ref` field
7956
+ * selects its release perspective; otherwise it inherits the parent's.
7957
+ *
7958
+ * Pass `[releaseName]` to read under a Content Release, or
7959
+ * `[releaseName, 'drafts']` to include drafts. Engine-owned instance and
7960
+ * definition documents, and `system.release` documents, always read under `raw`.
7510
7961
  */
7511
7962
  perspective?: WorkflowPerspective;
7512
7963
  }
@@ -7672,12 +8123,11 @@ export declare function stripSystemFields(
7672
8123
  ): Record<string, unknown>;
7673
8124
 
7674
8125
  /**
7675
- * Why an in-flight instance is genuinely blocked — nothing advances it on its
7676
- * own OR via a normal action. Ordered most- to least-actionable in
7677
- * {@link diagnoseInstance}: a failed effect is the root cause even when it left
7678
- * its activity looking merely "active", so it wins over the activity- and
7679
- * transition-level symptoms it produces. Note an active activity awaiting a human
7680
- * action is NOT here — that's the healthy {@link Diagnosis} `waiting` state.
8126
+ * A fault or missing dependency in an in-flight instance. Missing documents
8127
+ * follow effect/activity faults and precede transition faults. The diagnosis
8128
+ * is advisory: it does not prohibit actions that can still run.
8129
+ * An active activity awaiting a human action is the healthy
8130
+ * {@link Diagnosis} `waiting` state.
7681
8131
  *
7682
8132
  * `transition-unevaluable` is the recoverable arm: every activity resolved,
7683
8133
  * but an exit transition's `when` came back GROQ `null` (a referenced operand
@@ -7686,6 +8136,10 @@ export declare function stripSystemFields(
7686
8136
  * definite `false`. It carries the undecidable transitions.
7687
8137
  */
7688
8138
  export declare type StuckCause =
8139
+ | {
8140
+ kind: "document-missing";
8141
+ documents: MissingDocument[];
8142
+ }
7689
8143
  | {
7690
8144
  kind: "failed-effect";
7691
8145
  effect: EffectHistoryEntry;
@@ -7840,17 +8294,27 @@ export declare interface SubworkflowEntry {
7840
8294
  }
7841
8295
 
7842
8296
  /**
7843
- * Fan-out declared as an action's `spawn`, read back as `$subworkflows`.
7844
- * `forEach` is GROQ producing one row per subworkflow (bound as `$row`); each
7845
- * row needs an identity the engine can adopt on re-entry (`_key` ?? `_id` ??
7846
- * GDR `id`, or the value itself for a scalar row) or the spawn fails.
7847
- * `definition` resolves by stable `name`, ordered `version desc` unless
7848
- * pinned. `with` seeds each child's initial fields; `context` delivers extra
7849
- * parent-scope values into the child's `$context`. `onExit` governs only
7850
- * still-live children when the cohort's scope stops applying: `'detach'`
7851
- * (default) lets them run to completion, `'abort'` kills them recursively —
7852
- * always an authored choice, never automatic. Whether the PARENT may move at
7853
- * all is a separate gate over `$subworkflows`.
8297
+ * Child workflows created by an action's `spawn`, exposed as `$subworkflows`.
8298
+ * `definition` selects the highest deployed version unless a version is pinned.
8299
+ *
8300
+ * `forEach` evaluates with workflow fields only and no caller variables, even
8301
+ * for a caller-fired action. Rows need unique identities: a nonempty `_key`,
8302
+ * then `_id`, then a GDR's `id`, or a scalar's string representation.
8303
+ * Missing or duplicate identities reject the spawn. Re-entry adopts matching
8304
+ * live children from the same activity, action, and definition instead of
8305
+ * duplicating them.
8306
+ *
8307
+ * `with` maps child input-field names to expressions evaluated with `$row`.
8308
+ * `context` evaluates once without `$row` and supplies the child's `$context`.
8309
+ * Both use the parent activity's field scope and the acting identity when
8310
+ * available. Neither binds `$can`, `$attributes`, or `$params`.
8311
+ * Context results must be strings, numbers, booleans, or full GDRs; null and
8312
+ * undefined omit the entry. Other objects and arrays reject the spawn.
8313
+ *
8314
+ * `onExit` governs live children when their cohort leaves scope: `detach`
8315
+ * (the default) leaves them running; `abort` stops them recursively. Aborting
8316
+ * the parent always stops its children. Parent transitions must separately
8317
+ * declare whether they wait for the cohort to settle.
7854
8318
  *
7855
8319
  * @interface
7856
8320
  */
@@ -8022,7 +8486,7 @@ export declare interface TelemetryIntake {
8022
8486
  * closes the socket (a `Promise.race` alone cannot). */
8023
8487
  export declare interface TelemetryIntakeClient {
8024
8488
  request: <T>(opts: {
8025
- uri: string;
8489
+ url: string;
8026
8490
  method?: string;
8027
8491
  body?: unknown;
8028
8492
  tag?: string;
@@ -8085,14 +8549,14 @@ export declare interface TodoListItem {
8085
8549
  }
8086
8550
 
8087
8551
  /**
8088
- * A pure edge — `{name, when, to}` plus presentation, no ops or effects
8089
- * (structure never does; only actions do). Every transition is evaluated on
8090
- * every commit and cascade; the first truthy `when` in declaration order
8091
- * fires. No action coupling: a routing difference is written into fields by
8092
- * an action and read by the trigger — arrival work is a `when: 'true'`
8093
- * action in the destination stage, and exit work is an action in the source
8094
- * stage whose `when` repeats this transition's condition (the hop rule
8095
- * guarantees it commits before the move).
8552
+ * A one-way route to another stage, without operations or effects. Selection
8553
+ * checks `when` conditions in declaration order. The first satisfied condition
8554
+ * fires; an earlier unevaluable condition, such as GROQ null, stops selection
8555
+ * without considering later routes. A false condition permits the next route.
8556
+ *
8557
+ * Actions write routing decisions into fields; transitions read that state.
8558
+ * Source-stage triggered actions run before transition selection. Arrival work
8559
+ * belongs to a triggered action in a nonterminal destination stage.
8096
8560
  */
8097
8561
  export declare type Transition = TransitionFields & {
8098
8562
  when: string;
@@ -8217,10 +8681,18 @@ export declare interface ValidationIssue {
8217
8681
  }
8218
8682
 
8219
8683
  /**
8220
- * An op's write payload, resolved to concrete JSON when the op applies. Each
8221
- * context-bound arm has a rendered `$`-twin in conditions (`actor`
8222
- * `$actor`, `now` `$now`, `self` `$self`), so learning one side teaches
8223
- * the other. Distinct from {@link FieldSource}, a field's seed recipe.
8684
+ * An operation's write value, resolved when the operation applies.
8685
+ * `param` reads a caller-supplied action argument; `actor` records the acting
8686
+ * identity. `now` supplies the operation's ISO timestamp, `self` its instance's
8687
+ * GDR URI, and `stage` the current stage name. `object` resolves its fields
8688
+ * recursively.
8689
+ *
8690
+ * A `fieldRead` with no scope searches activity, stage, then workflow fields.
8691
+ * An explicit scope searches only that scope. A pathless read from a subject
8692
+ * or `doc.ref` into another subject or `doc.ref` preserves the stored reference.
8693
+ * Other reads use the referenced snapshot document, or only its `_id` and
8694
+ * `_type` when it is not loaded. No additional documents are fetched.
8695
+ * Initialization uses {@link FieldSource}, whose field-read scope rules differ.
8224
8696
  */
8225
8697
  export declare type ValueExpr = ValueExprInternal;
8226
8698
 
@@ -8325,17 +8797,20 @@ export { withAssignment };
8325
8797
 
8326
8798
  export declare const workflow: {
8327
8799
  /**
8328
- * Deploy a set of definitions as one call. Definitions are immutable and
8329
- * content-addressed: the author writes no version, identical content no-ops
8330
- * (`unchanged`), and any change mints the next version (`created`) — deploy
8331
- * never patches a deployed version out from under the instances pinned to it.
8332
- * The engine orders the batch itself (children before the parents that spawn
8333
- * them). Refs may point inside the batch or at already-deployed definitions;
8334
- * a ref resolving to neither, or a cycle, errors before any write. Input is
8335
- * authored content or a fetched definition document the document envelope
8336
- * (`_*` system fields, `tag`, `version`, `contentHash`) is stripped at the
8337
- * boundary and never fingerprinted, so a fetched document redeploys as
8338
- * `unchanged`; any other unknown key fails loud.
8800
+ * Deploys immutable definition versions. The engine assigns each version:
8801
+ * content matching the latest deployed fingerprint returns `unchanged`;
8802
+ * otherwise deployment creates the next version and returns `created`.
8803
+ * Redeploying older content creates a new version; existing versions and
8804
+ * their pinned instances are unchanged.
8805
+ *
8806
+ * Children deploy before parents. References may resolve within the batch
8807
+ * or to deployed definitions; unresolved references and cycles reject the
8808
+ * batch before any write.
8809
+ *
8810
+ * Accepts authored content or a fetched definition document. The document
8811
+ * envelope (`_*` system fields, `tag`, `version`, `contentHash`) is excluded
8812
+ * from the fingerprint. Fetched content follows the same latest-version
8813
+ * comparison; any other unknown input key is rejected.
8339
8814
  */
8340
8815
  deployDefinitions: <T extends WorkflowDefinitionInput<T>>(
8341
8816
  rawArgs: Telemetered<DeployDefinitionsArgs<T> & EngineScopeArgs>,
@@ -8708,17 +9183,20 @@ export declare interface WorkflowAutonomy extends AutonomyAnswer {
8708
9183
  }
8709
9184
 
8710
9185
  export declare interface WorkflowClient {
9186
+ /** Build a resource-bound data URL, as on SanityClient. Used to confirm document availability. */
9187
+ getDataUrl?: (operation: string, path?: string) => string;
8711
9188
  /**
8712
- * Read the effective client configuration. The engine reads two fields from
8713
- * it. `apiHost` is probed before deriving the global `/users/me` sibling,
8714
- * because `@sanity/client` shallow-merges `withConfig` overrides and
8715
- * otherwise preserves an explicit project host even when
8716
- * `useProjectHostname` is set to `false`. `projectId` addresses the project's
8717
- * user directory when a project-scoped principal has to be bridged to its
8718
- * account-global id a client reporting none has no directory to ask, and
8719
- * such a session is refused rather than stamped locally.
9189
+ * Read the effective client configuration. The engine uses `apiHost` for
9190
+ * account-global identity routing and `projectId` for project directory and
9191
+ * organization lookups. Without `projectId`, organization attributes cannot
9192
+ * be loaded and project-scoped principals cannot use the directory bridge.
9193
+ *
9194
+ * For clients without {@link WorkflowClient.withConfig}, an omitted
9195
+ * `apiVersion` means the implementation must already serve
9196
+ * {@link ENGINE_API_VERSION}. A declared `apiVersion` other than that version
9197
+ * skips organization attributes with a warning.
8720
9198
  */
8721
- config?: () => WorkflowClientConfig;
9199
+ config?: () => WorkflowClientConfigState;
8722
9200
  fetch: <T = unknown>(
8723
9201
  query: string,
8724
9202
  params?: Record<string, unknown>,
@@ -8819,21 +9297,12 @@ export declare interface WorkflowClient {
8819
9297
  * discovery uses its dry-run fallback, while a definition containing
8820
9298
  * role-constrained assignment fields fails loudly because the engine cannot
8821
9299
  * read the project membership directory required to validate assignees.
9300
+ *
9301
+ * Raw request transport. The engine passes the request target through
9302
+ * `url`; relative paths must resolve against the client's configured API
9303
+ * host, matching supported `SanityClient.request` implementations.
8822
9304
  */
8823
- request?: <T>(opts: {
8824
- /** Raw URL (host + path). One of `url` / `uri` required. */
8825
- url?: string;
8826
- /**
8827
- * Project-scoped path resolved against the `@sanity/client`'s
8828
- * apiHost (e.g. `/users/me` → `https://api.sanity.io/v1/users/me`).
8829
- * Use this for global endpoints like `/users/me`. Mirrors
8830
- * `SanityClient.request({uri})` in `@sanity/client`.
8831
- */
8832
- uri?: string;
8833
- signal?: AbortSignal;
8834
- /** Optional `?tag=` query for observability — supported by `@sanity/client`. */
8835
- tag?: string;
8836
- }) => Promise<T>;
9305
+ request?: <T>(opts: WorkflowRequestOptions) => Promise<T>;
8837
9306
  }
8838
9307
 
8839
9308
  /**
@@ -8859,6 +9328,17 @@ export declare interface WorkflowClientConfig {
8859
9328
  useProjectHostname?: boolean;
8860
9329
  }
8861
9330
 
9331
+ /** The engine reads only project and API metadata from this value. */
9332
+ export declare interface WorkflowClientConfigState extends Omit<
9333
+ WorkflowClientConfig,
9334
+ "resource"
9335
+ > {
9336
+ resource?: {
9337
+ type: string;
9338
+ id: string;
9339
+ };
9340
+ }
9341
+
8862
9342
  export declare interface WorkflowCommitOptions {
8863
9343
  /**
8864
9344
  * When the mutation becomes visible to subsequent queries. The engine
@@ -9168,44 +9648,22 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9168
9648
  readonly [
9169
9649
  v.ArraySchema<
9170
9650
  v.CustomSchema<
9171
- {
9172
- name: string;
9173
- semantics?: Semantic[] | undefined;
9174
- title: string;
9175
- description?: string | undefined;
9176
- groups?: Group[] | undefined;
9177
- lifecycle?: WorkflowLifecycle | undefined;
9178
- start?: StartBlock | undefined;
9179
- initialStage: string;
9180
- fields?: FieldEntry[] | undefined;
9181
- stages: Stage[];
9182
- predicates?: Record<string, string> | undefined;
9183
- roleAliases?: RoleAliases | undefined;
9184
- },
9651
+ DefinedWorkflow,
9185
9652
  v.ErrorMessage<v.CustomIssue> | undefined
9186
9653
  >,
9187
9654
  undefined
9188
9655
  >,
9189
9656
  v.MinLengthAction<
9190
- {
9191
- name: string;
9192
- semantics?: Semantic[] | undefined;
9193
- title: string;
9194
- description?: string | undefined;
9195
- groups?: Group[] | undefined;
9196
- lifecycle?: WorkflowLifecycle | undefined;
9197
- start?: StartBlock | undefined;
9198
- initialStage: string;
9199
- fields?: FieldEntry[] | undefined;
9200
- stages: Stage[];
9201
- predicates?: Record<string, string> | undefined;
9202
- roleAliases?: RoleAliases | undefined;
9203
- }[],
9657
+ DefinedWorkflow[],
9204
9658
  1,
9205
9659
  "a deployment needs at least one definition"
9206
9660
  >,
9207
9661
  ]
9208
9662
  >;
9663
+ readonly runtime: v.OptionalSchema<
9664
+ v.GenericSchema<RuntimeBlock>,
9665
+ undefined
9666
+ >;
9209
9667
  },
9210
9668
  undefined
9211
9669
  >,
@@ -9255,20 +9713,8 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9255
9713
  };
9256
9714
  }[]
9257
9715
  | undefined;
9258
- definitions: {
9259
- name: string;
9260
- semantics?: Semantic[] | undefined;
9261
- title: string;
9262
- description?: string | undefined;
9263
- groups?: Group[] | undefined;
9264
- lifecycle?: WorkflowLifecycle | undefined;
9265
- start?: StartBlock | undefined;
9266
- initialStage: string;
9267
- fields?: FieldEntry[] | undefined;
9268
- stages: Stage[];
9269
- predicates?: Record<string, string> | undefined;
9270
- roleAliases?: RoleAliases | undefined;
9271
- }[];
9716
+ definitions: DefinedWorkflow[];
9717
+ runtime?: RuntimeBlock | undefined;
9272
9718
  }[],
9273
9719
  1,
9274
9720
  "a config needs at least one deployment"
@@ -9317,20 +9763,8 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9317
9763
  };
9318
9764
  }[]
9319
9765
  | undefined;
9320
- definitions: {
9321
- name: string;
9322
- semantics?: Semantic[] | undefined;
9323
- title: string;
9324
- description?: string | undefined;
9325
- groups?: Group[] | undefined;
9326
- lifecycle?: WorkflowLifecycle | undefined;
9327
- start?: StartBlock | undefined;
9328
- initialStage: string;
9329
- fields?: FieldEntry[] | undefined;
9330
- stages: Stage[];
9331
- predicates?: Record<string, string> | undefined;
9332
- roleAliases?: RoleAliases | undefined;
9333
- }[];
9766
+ definitions: DefinedWorkflow[];
9767
+ runtime?: RuntimeBlock | undefined;
9334
9768
  }[],
9335
9769
  (
9336
9770
  issue: v.CheckIssue<
@@ -9377,20 +9811,8 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9377
9811
  };
9378
9812
  }[]
9379
9813
  | undefined;
9380
- definitions: {
9381
- name: string;
9382
- semantics?: Semantic[] | undefined;
9383
- title: string;
9384
- description?: string | undefined;
9385
- groups?: Group[] | undefined;
9386
- lifecycle?: WorkflowLifecycle | undefined;
9387
- start?: StartBlock | undefined;
9388
- initialStage: string;
9389
- fields?: FieldEntry[] | undefined;
9390
- stages: Stage[];
9391
- predicates?: Record<string, string> | undefined;
9392
- roleAliases?: RoleAliases | undefined;
9393
- }[];
9814
+ definitions: DefinedWorkflow[];
9815
+ runtime?: RuntimeBlock | undefined;
9394
9816
  }[]
9395
9817
  >,
9396
9818
  ) => string
@@ -9439,20 +9861,8 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9439
9861
  };
9440
9862
  }[]
9441
9863
  | undefined;
9442
- definitions: {
9443
- name: string;
9444
- semantics?: Semantic[] | undefined;
9445
- title: string;
9446
- description?: string | undefined;
9447
- groups?: Group[] | undefined;
9448
- lifecycle?: WorkflowLifecycle | undefined;
9449
- start?: StartBlock | undefined;
9450
- initialStage: string;
9451
- fields?: FieldEntry[] | undefined;
9452
- stages: Stage[];
9453
- predicates?: Record<string, string> | undefined;
9454
- roleAliases?: RoleAliases | undefined;
9455
- }[];
9864
+ definitions: DefinedWorkflow[];
9865
+ runtime?: RuntimeBlock | undefined;
9456
9866
  }[],
9457
9867
  (
9458
9868
  issue: v.CheckIssue<
@@ -9499,20 +9909,8 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9499
9909
  };
9500
9910
  }[]
9501
9911
  | undefined;
9502
- definitions: {
9503
- name: string;
9504
- semantics?: Semantic[] | undefined;
9505
- title: string;
9506
- description?: string | undefined;
9507
- groups?: Group[] | undefined;
9508
- lifecycle?: WorkflowLifecycle | undefined;
9509
- start?: StartBlock | undefined;
9510
- initialStage: string;
9511
- fields?: FieldEntry[] | undefined;
9512
- stages: Stage[];
9513
- predicates?: Record<string, string> | undefined;
9514
- roleAliases?: RoleAliases | undefined;
9515
- }[];
9912
+ definitions: DefinedWorkflow[];
9913
+ runtime?: RuntimeBlock | undefined;
9516
9914
  }[]
9517
9915
  >,
9518
9916
  ) => string
@@ -9600,35 +9998,22 @@ export declare interface WorkflowDefinitionDeployedData {
9600
9998
  * of a literal is a finite key union that `string` never extends) — i.e. how
9601
9999
  * fetch results are typed (`Record<string, unknown>`), which pass through to
9602
10000
  * the runtime boundary parse. Everything precisely typed gets the exact
9603
- * {@link WorkflowDefinition} contract: beyond the document envelope
9604
- * (the closed system-key union, so a typed {@link DeployedDefinition} passes
9605
- * castless), unknown keys are `never` a typo'd literal is a compile error,
9606
- * never a silent collapse to the record arm.
10001
+ * {@link WorkflowDefinition} contract with two accepted exceptions: the
10002
+ * document envelope (the closed system-key union, so a typed
10003
+ * {@link DeployedDefinition} passes castless) and the authoring-only root
10004
+ * `runtime` block, so a {@link DefinedWorkflow} passes castless too. Every
10005
+ * other unknown key is `never`, making a typo'd literal a compile error rather
10006
+ * than a silent collapse to the record arm.
9607
10007
  */
9608
10008
  export declare type WorkflowDefinitionInput<T> = string extends keyof T
9609
10009
  ? Record<string, unknown>
9610
10010
  : WorkflowDefinition & {
9611
10011
  [K in Exclude<
9612
10012
  keyof T,
9613
- keyof WorkflowDefinition | DocumentEnvelopeKey
10013
+ keyof WorkflowDefinition | DocumentEnvelopeKey | AuthoringRuntimeKey
9614
10014
  >]?: never;
9615
10015
  };
9616
10016
 
9617
- /**
9618
- * Structural schema for a STORED workflow definition — primitives only,
9619
- * every reference scope resolved. Cross-field invariants (unique names,
9620
- * transition targets, effect-name uniqueness, predicate shadowing) are
9621
- * checked by `checkWorkflowInvariants` after desugar — see `defineWorkflow`.
9622
- * Carries NO `version`: a definition's version and content fingerprint are
9623
- * stamped onto the deployed document at deploy time, derived from the
9624
- * content itself, so redeploying identical content is a no-op and any
9625
- * change mints the next version.
9626
- *
9627
- * Exported (module-level, not package API) for the model-surface gate's
9628
- * coverage test and for `parseStoredDefinition` — the boundary parse for a
9629
- * definition that did not come out of `defineWorkflow` in-process; trusted
9630
- * in-process desugar output is never re-parsed.
9631
- */
9632
10017
  declare const WorkflowDefinitionSchema: v.GenericSchema<
9633
10018
  WorkflowFields<FieldEntry, Stage, StartBlock>
9634
10019
  >;
@@ -9640,10 +10025,22 @@ declare const WorkflowDefinitionSchema: v.GenericSchema<
9640
10025
  export declare type WorkflowDeployment = WorkflowConfig["deployments"][number];
9641
10026
 
9642
10027
  /**
9643
- * What an author writes for one deployment: the highest reader model verified
9644
- * across runtimes sharing its workflow resource. Runtime validation compares
9645
- * it with the submitted definitions, so a dependency upgrade alone does not
9646
- * require changing the literal.
10028
+ * Author one deployment with a nonempty `definitions` array and a
10029
+ * {@link WorkflowResource}. Dataset resource IDs use `<projectId>.<dataset>`.
10030
+ *
10031
+ * `name` and `tag` must contain only ASCII lowercase letters, digits, and dashes,
10032
+ * starting with a letter or digit. Deployment names and `(workflowResource, tag)`
10033
+ * pairs must be unique across the config. Optional `resourceAliases` use the same
10034
+ * name grammar, with unique names within this deployment.
10035
+ *
10036
+ * `expectedMinReaderModel` is the highest reader model you have verified across
10037
+ * runtimes sharing the workflow resource. Supply a reviewed numeric literal.
10038
+ * Definition submission checks it against the required reader floor; upgrading
10039
+ * a dependency alone does not require changing it.
10040
+ *
10041
+ * `runtime` is the default hosting kind for this deployment's workflows, which
10042
+ * each workflow and effect may override. Omitted, its workflows host on
10043
+ * `'function'`.
9647
10044
  */
9648
10045
  export declare type WorkflowDeploymentInput = Omit<
9649
10046
  WorkflowDeployment,
@@ -9745,6 +10142,16 @@ export declare type WorkflowErrorKind =
9745
10142
  export declare interface WorkflowEvaluation {
9746
10143
  instance: WorkflowInstance;
9747
10144
  definition: WorkflowDefinition;
10145
+ /** Missing targets of populated subject, doc.ref, and doc.refs fields in active
10146
+ * scopes. Clears on resolution; empty fields and exited-stage fields are excluded.
10147
+ * Required reference declarations and runtime conditions determine whether absence blocks progress. */
10148
+ missingDocuments?: MissingDocument[];
10149
+ /**
10150
+ * Missing required reference targets, or references read by unmet runtime requirements or transition conditions,
10151
+ * including named predicates in their evaluated scope. Empty when missing references
10152
+ * are optional for current progress. Omitted when no references are missing.
10153
+ */
10154
+ blockingMissingDocuments?: MissingDocument[];
9748
10155
  /** The workflow's advisory meaning, unchanged from its definition. */
9749
10156
  semantics?: Semantic[] | undefined;
9750
10157
  actor: Actor;
@@ -9776,11 +10183,14 @@ export declare interface WorkflowEvaluation {
9776
10183
  */
9777
10184
  autonomy: WorkflowAutonomy;
9778
10185
  /**
9779
- * The nearest future instant (ISO 8601) at which the clock alone changes this
9780
- * projection; re-evaluate then. Includes a gate reading `$now` beside
9781
- * `$actor`, `$assigned`, `$can`, or `$attributes`, evaluated in this actor's
9782
- * scopes. Derived per call, never persisted. Absent on a terminal instance
9783
- * and when no site yields a boundary from those scopes.
10186
+ * The earliest future ISO 8601 instant the engine can derive for a time-based
10187
+ * change to this evaluation. Re-evaluate then. Includes a gate reading `$now`
10188
+ * beside `$actor`, `$assigned`, `$can`, or `$attributes`, evaluated in this
10189
+ * actor's scopes. Derived per call, never persisted.
10190
+ *
10191
+ * Absent on a terminal instance or when the engine cannot derive a boundary.
10192
+ * Conditions using date arithmetic may yield no boundary. Time can still
10193
+ * affect a nonterminal instance when this value is absent.
9784
10194
  */
9785
10195
  nextEvaluationAt?: string;
9786
10196
  }
@@ -9871,15 +10281,14 @@ export declare interface WorkflowInstance extends SanityDocument {
9871
10281
  /** Frozen JSON snapshot of the definition at the moment the instance started. */
9872
10282
  definitionSnapshot: string;
9873
10283
  /**
9874
- * Workflow-level resolved field entries.
9875
- * Populated from the workflow definition's `fields[]` declarations plus
9876
- * the caller-supplied `initialFields` at `startInstance`. Persists for
9877
- * the lifetime of the instance.
10284
+ * Resolved workflow fields, retained for the instance's lifetime. Their
10285
+ * initial values come from the definition's `fields` declarations and
10286
+ * {@link StartInstanceArgs.initialFields}.
9878
10287
  *
9879
- * To declare "the subject document of this workflow", add a
9880
- * `{ type: "doc.ref", name: "subject", initialValue: { type: "input" } }`
9881
- * entry to the workflow definition. Conditions then read it as
9882
- * `$fields.subject`. There is no other subject mechanism.
10288
+ * To declare the workflow's subject document, use
10289
+ * `{type: 'subject', name: 'subject', initialValue: {type: 'input'}}`.
10290
+ * Conditions read that entry as `$fields.subject`. The `subject` field
10291
+ * type identifies its role; naming a `doc.ref` field `subject` does not.
9883
10292
  */
9884
10293
  fields: ResolvedFieldEntry[];
9885
10294
  /**
@@ -9895,14 +10304,13 @@ export declare interface WorkflowInstance extends SanityDocument {
9895
10304
  */
9896
10305
  ancestors: GlobalDocumentReference[];
9897
10306
  /**
9898
- * Optional perspective applied to field-entry query reads and spawn
9899
- * `forEach.groq` discovery. When unset the engine treats reads as
9900
- * `"raw"` (no filtering). Set at `startInstance` time to scope a
9901
- * workflow's reads to a Content Release stack (e.g. `[releaseName]`
9902
- * or `[releaseName, "drafts"]`).
10307
+ * Perspective for content reads, including field queries and subworkflow
10308
+ * discovery. Defaults to {@link DEFAULT_CONTENT_PERSPECTIVE}, where drafts
10309
+ * take precedence over published content. Set it through
10310
+ * {@link StartInstanceArgs.perspective}; child instances inherit it.
9903
10311
  *
9904
- * Engine-internal reads of instance / definition documents are
9905
- * always raw, regardless of this field.
10312
+ * Engine-owned instance and definition documents, and `system.release`
10313
+ * documents, always read under `raw`.
9906
10314
  */
9907
10315
  perspective?: WorkflowPerspective;
9908
10316
  currentStage: StageName;
@@ -10076,6 +10484,14 @@ export declare type WorkflowPerspective =
10076
10484
  | "drafts"
10077
10485
  | string[];
10078
10486
 
10487
+ export declare interface WorkflowRequestOptions {
10488
+ /** API-relative path resolved against the configured API host, or an absolute URL. */
10489
+ url: string;
10490
+ signal?: AbortSignal;
10491
+ /** Optional `?tag=` query for observability — supported by `@sanity/client`. */
10492
+ tag?: string;
10493
+ }
10494
+
10079
10495
  /**
10080
10496
  * The resource a Sanity client is configured against — mirrors
10081
10497
  * `@sanity/client`'s `ClientConfigResource` discriminator. For