@lostgradient/weft 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/api.d.ts +2 -0
  3. package/dist/cli/api.js +3 -4
  4. package/dist/cli/generated/operation-catalog.snapshot.json +5167 -0
  5. package/dist/cli/generated/operation-client.generated.d.ts +119 -10
  6. package/dist/cli/generated/operation-client.generated.js +74 -1
  7. package/dist/cli/index.js +1 -0
  8. package/dist/cli/operation-catalog-snapshot.d.ts +11 -2
  9. package/dist/cli/operation-catalog-snapshot.js +14 -5
  10. package/dist/cli/operation-client-runtime.d.ts +29 -0
  11. package/dist/cli-main.js +227 -401
  12. package/dist/client/client-storage.d.ts +24 -0
  13. package/dist/client/client-storage.js +14 -0
  14. package/dist/client/handle-delegation.d.ts +3 -3
  15. package/dist/client/handle-delegation.js +2 -2
  16. package/dist/client/http-client-requests.d.ts +5 -3
  17. package/dist/client/http-client-requests.js +20 -2
  18. package/dist/client/http-client-storage.d.ts +3 -0
  19. package/dist/client/http-client-storage.js +110 -0
  20. package/dist/client/http-client.d.ts +9 -6
  21. package/dist/client/http-client.js +13 -18
  22. package/dist/client/http-operations.d.ts +3 -1
  23. package/dist/client/http-operations.js +84 -2
  24. package/dist/client/http-request.d.ts +35 -6
  25. package/dist/client/http-request.js +31 -10
  26. package/dist/client/in-process-operations.d.ts +2 -2
  27. package/dist/client/in-process-operations.js +2 -2
  28. package/dist/client/index.d.ts +6 -0
  29. package/dist/client/index.js +18 -0
  30. package/dist/client/interface.d.ts +26 -26
  31. package/dist/client/local.d.ts +9 -6
  32. package/dist/client/local.js +9 -4
  33. package/dist/client/search-params.js +10 -6
  34. package/dist/client/start-body.d.ts +3 -1
  35. package/dist/client/start-body.js +9 -0
  36. package/dist/connection.d.ts +8 -0
  37. package/dist/connection.js +41 -17
  38. package/dist/core/bulk-workflow-filter.d.ts +2 -1
  39. package/dist/core/bulk-workflow-filter.js +5 -1
  40. package/dist/core/engine/async-activity-records.d.ts +12 -1
  41. package/dist/core/engine/async-activity-records.js +81 -2
  42. package/dist/core/engine/bulk-operations-purge.js +16 -1
  43. package/dist/core/engine/bulk-operations-shared.js +2 -0
  44. package/dist/core/engine/callback-creators-core.js +2 -1
  45. package/dist/core/engine/callback-creators-schedule.d.ts +2 -1
  46. package/dist/core/engine/callback-creators-schedule.js +3 -3
  47. package/dist/core/engine/checkpoint-reads.js +11 -1
  48. package/dist/core/engine/child-workflow.js +15 -6
  49. package/dist/core/engine/construction.js +3 -0
  50. package/dist/core/engine/disposal.js +2 -0
  51. package/dist/core/engine/engine-internal-types.d.ts +4 -1
  52. package/dist/core/engine/fenced-write.d.ts +5 -3
  53. package/dist/core/engine/finalizer-status.d.ts +10 -0
  54. package/dist/core/engine/finalizer-status.js +82 -0
  55. package/dist/core/engine/index.d.ts +69 -2
  56. package/dist/core/engine/index.js +71 -8
  57. package/dist/core/engine/internals.d.ts +3 -0
  58. package/dist/core/engine/lease-health.d.ts +64 -0
  59. package/dist/core/engine/lease-health.js +0 -0
  60. package/dist/core/engine/lease-manager.d.ts +4 -2
  61. package/dist/core/engine/lease-manager.js +32 -4
  62. package/dist/core/engine/lifecycle/recovered-services.js +0 -2
  63. package/dist/core/engine/lifecycle/shared.d.ts +28 -0
  64. package/dist/core/engine/lifecycle/start-batch.js +12 -0
  65. package/dist/core/engine/lifecycle/start.d.ts +1 -1
  66. package/dist/core/engine/lifecycle/start.js +34 -5
  67. package/dist/core/engine/lifecycle/transition.js +19 -9
  68. package/dist/core/engine/operations-coordination.d.ts +1 -12
  69. package/dist/core/engine/operations-coordination.js +57 -10
  70. package/dist/core/engine/operations-speculate.d.ts +1 -1
  71. package/dist/core/engine/operations-speculate.js +19 -5
  72. package/dist/core/engine/registration.js +14 -0
  73. package/dist/core/engine/schedule-handle.d.ts +4 -4
  74. package/dist/core/engine/schedule-handle.js +2 -2
  75. package/dist/core/engine/schedule-overlap.d.ts +11 -0
  76. package/dist/core/engine/schedule-overlap.js +50 -0
  77. package/dist/core/engine/schedule-run.d.ts +11 -3
  78. package/dist/core/engine/schedule-run.js +27 -4
  79. package/dist/core/engine/schedule-timer.js +10 -1
  80. package/dist/core/engine/schedules.d.ts +5 -4
  81. package/dist/core/engine/schedules.js +62 -56
  82. package/dist/core/engine/state-utilities.js +1 -1
  83. package/dist/core/engine/storage-io.d.ts +12 -0
  84. package/dist/core/engine/storage-io.js +49 -10
  85. package/dist/core/engine/termination/finalizer-claim.d.ts +8 -6
  86. package/dist/core/engine/termination/finalizer-claim.js +2 -1
  87. package/dist/core/engine/termination/finalizer.js +10 -14
  88. package/dist/core/engine/timeline-coordinator-constants.d.ts +3 -0
  89. package/dist/core/engine/timeline-coordinator-constants.js +1 -0
  90. package/dist/core/engine/timeline-coordinator-detail.d.ts +13 -0
  91. package/dist/core/engine/timeline-coordinator-detail.js +76 -0
  92. package/dist/core/engine/validation/schedule-options.d.ts +8 -1
  93. package/dist/core/engine/validation/schedule-options.js +18 -0
  94. package/dist/core/engine/validation/schedule.d.ts +1 -1
  95. package/dist/core/engine/validation/schedule.js +27 -3
  96. package/dist/core/engine/validation.js +66 -2
  97. package/dist/core/engine/workflow-state-stream.d.ts +5 -1
  98. package/dist/core/engine/workflow-state-stream.js +37 -14
  99. package/dist/core/events/schedule-events.d.ts +3 -4
  100. package/dist/core/events/workflow-events.d.ts +2 -1
  101. package/dist/core/list-filter-validation.d.ts +3 -0
  102. package/dist/core/list-filter-validation.js +11 -0
  103. package/dist/core/registry-snapshot.d.ts +32 -0
  104. package/dist/core/registry-snapshot.js +28 -0
  105. package/dist/core/review/index.d.ts +4 -4
  106. package/dist/core/types/activity.d.ts +52 -5
  107. package/dist/core/types/bulk.d.ts +1 -0
  108. package/dist/core/types/definition-schema-to-json.d.ts +11 -0
  109. package/dist/core/types/definition-schema-to-json.js +11 -2
  110. package/dist/core/types/list-options.d.ts +6 -0
  111. package/dist/core/types/options.d.ts +6 -5
  112. package/dist/core/types/reviews.d.ts +2 -2
  113. package/dist/core/types/schedules.d.ts +45 -2
  114. package/dist/core/types/services-resolution.d.ts +5 -5
  115. package/dist/core/types/state.d.ts +64 -0
  116. package/dist/core/types/workflow-log.d.ts +3 -2
  117. package/dist/core/types/workflow-observability.d.ts +50 -0
  118. package/dist/core/types/workflow-observability.js +0 -0
  119. package/dist/core/types/workflow-registry.d.ts +7 -0
  120. package/dist/core/types.d.ts +1 -0
  121. package/dist/core/types.js +1 -0
  122. package/dist/http.js +2 -0
  123. package/dist/index.d.ts +4 -3
  124. package/dist/indexeddb.js +1 -0
  125. package/dist/json-schema.js +3 -3
  126. package/dist/mcp/cli.js +63 -61
  127. package/dist/mcp/http.d.ts +7 -2
  128. package/dist/mcp/session.d.ts +3 -3
  129. package/dist/mcp/session.js +3 -2
  130. package/dist/mcp/stdio.d.ts +7 -2
  131. package/dist/observability/index.js +2 -2
  132. package/dist/runtime/portable.d.ts +33 -0
  133. package/dist/runtime/portable.js +17 -6
  134. package/dist/server/access-policy-metadata.d.ts +92 -0
  135. package/dist/server/access-policy-metadata.js +78 -0
  136. package/dist/server/engine-event-feed-backend.d.ts +22 -3
  137. package/dist/server/fault-to-http.d.ts +3 -7
  138. package/dist/server/fault-to-http.js +2 -34
  139. package/dist/server/fleet-event-feed.d.ts +65 -0
  140. package/dist/server/handler/index.d.ts +11 -2
  141. package/dist/server/handler/index.js +8 -1
  142. package/dist/server/handler/route-dispatch.d.ts +10 -3
  143. package/dist/server/handler/route-dispatch.js +19 -4
  144. package/dist/server/handler.js +1 -56
  145. package/dist/server/index.d.ts +13 -2
  146. package/dist/server/index.js +88 -64
  147. package/dist/server/interactive-operations.js +2 -0
  148. package/dist/server/openapi-error-responses.js +55 -4
  149. package/dist/server/openapi.d.ts +3 -1
  150. package/dist/server/openapi.js +4 -0
  151. package/dist/server/openrpc-document-schema.d.ts +64 -0
  152. package/dist/server/openrpc-document-schema.js +6 -26
  153. package/dist/server/openrpc.d.ts +4 -0
  154. package/dist/server/openrpc.js +9 -33
  155. package/dist/server/operation-fault.d.ts +24 -7
  156. package/dist/server/operation-fault.js +65 -13
  157. package/dist/server/operations/aggregate-workflows.d.ts +6 -0
  158. package/dist/server/operations/aggregate-workflows.js +3 -2
  159. package/dist/server/operations/async-activity.d.ts +14 -0
  160. package/dist/server/operations/async-activity.js +88 -4
  161. package/dist/server/operations/bulk-filter-helpers.d.ts +3 -0
  162. package/dist/server/operations/bulk-filter-helpers.js +27 -3
  163. package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +6 -0
  164. package/dist/server/operations/bulk-signal-workflows.d.ts +6 -0
  165. package/dist/server/operations/get-stream-chunks.js +2 -7
  166. package/dist/server/operations/get-system-lease.d.ts +19 -0
  167. package/dist/server/operations/get-system-lease.js +48 -0
  168. package/dist/server/operations/get-workflow-observability.d.ts +24 -0
  169. package/dist/server/operations/get-workflow-observability.js +80 -0
  170. package/dist/server/operations/get-workflow-result.js +2 -2
  171. package/dist/server/operations/get-workflow.d.ts +2 -2
  172. package/dist/server/operations/list-filter-query-extractor.js +15 -0
  173. package/dist/server/operations/list-workflows.d.ts +6 -0
  174. package/dist/server/operations/list-workflows.js +12 -3
  175. package/dist/server/operations/operation-helpers.d.ts +9 -18
  176. package/dist/server/operations/operation-helpers.js +5 -23
  177. package/dist/server/operations/purge-workflows.d.ts +3 -0
  178. package/dist/server/operations/recover-all.js +2 -1
  179. package/dist/server/operations/single-workflow-tag-mutation.js +2 -2
  180. package/dist/server/operations/sse-stream.js +2 -7
  181. package/dist/server/operations/storage-capabilities.d.ts +34 -0
  182. package/dist/server/operations/storage-capabilities.js +38 -0
  183. package/dist/server/operations/storage.js +8 -17
  184. package/dist/server/operations/stream-workflow-sse.js +3 -9
  185. package/dist/server/operations/submit-review-decision.d.ts +2 -0
  186. package/dist/server/operations/submit-review-decision.js +19 -2
  187. package/dist/server/operations/update-schedule.d.ts +8 -0
  188. package/dist/server/operations/update-schedule.js +70 -7
  189. package/dist/server/operations/workflow-events-sse.js +2 -2
  190. package/dist/server/replay-live-feed-internals.d.ts +19 -0
  191. package/dist/server/replay-live-feed-internals.js +76 -0
  192. package/dist/server/rest-binding.d.ts +7 -6
  193. package/dist/server/rest-bindings.d.ts +2 -13
  194. package/dist/server/rest-bindings.js +19 -10
  195. package/dist/server/runtime/authentication-bridge.d.ts +2 -2
  196. package/dist/server/serve-internals.js +3 -3
  197. package/dist/server/task-queue.d.ts +7 -5
  198. package/dist/server/workflow-event-feed.d.ts +100 -11
  199. package/dist/server/workflow-event-feed.js +1 -140
  200. package/dist/service-worker/index.d.ts +8 -2
  201. package/dist/service-worker/index.js +37 -56
  202. package/dist/service-worker/setup.d.ts +6 -2
  203. package/dist/storage/auto.js +1 -1
  204. package/dist/storage/bun-sql.js +3 -3
  205. package/dist/storage/capabilities.d.ts +1 -1
  206. package/dist/storage/cloudflare-durable-object-sql.d.ts +75 -0
  207. package/dist/storage/cloudflare-durable-object-sql.js +0 -0
  208. package/dist/storage/cloudflare-value-codec.d.ts +67 -0
  209. package/dist/storage/cloudflare-value-codec.js +46 -0
  210. package/dist/storage/cloudflare.d.ts +140 -0
  211. package/dist/storage/cloudflare.js +127 -0
  212. package/dist/storage/compressed-storage.js +1 -1
  213. package/dist/storage/http.js +200 -2
  214. package/dist/storage/index.d.ts +8 -1
  215. package/dist/storage/indexeddb.js +311 -1
  216. package/dist/storage/interface.d.ts +16 -4
  217. package/dist/storage/interface.js +1 -1
  218. package/dist/storage/key-prefixes.d.ts +1 -1
  219. package/dist/storage/key-prefixes.js +4 -0
  220. package/dist/storage/lmdb.js +1 -1
  221. package/dist/storage/memory.js +1 -1
  222. package/dist/storage/neon.js +4 -4
  223. package/dist/storage/node-sqlite.js +3 -3
  224. package/dist/storage/postgres-key-value-queries.d.ts +6 -0
  225. package/dist/storage/postgres-key-value-queries.js +2 -3
  226. package/dist/storage/postgres.js +4 -4
  227. package/dist/storage/resolve.js +1 -1
  228. package/dist/storage/scoped-storage.js +1 -1
  229. package/dist/storage/sql-identifier.d.ts +35 -0
  230. package/dist/storage/sql-identifier.js +5 -0
  231. package/dist/storage/sqlite-key-value-queries.d.ts +11 -6
  232. package/dist/storage/sqlite-key-value-queries.js +3 -3
  233. package/dist/storage/testing.js +1 -1
  234. package/dist/storage/turso.js +2 -2
  235. package/dist/storage/typed-storage.js +138 -2
  236. package/dist/storage/web-extension.js +298 -1
  237. package/dist/testing/index.js +21 -60
  238. package/dist/version.d.ts +1 -1
  239. package/dist/version.js +1 -1
  240. package/dist/web-extension.js +1 -0
  241. package/dist/worker/protocol.js +1 -1
  242. package/package.json +8 -3
@@ -1,11 +1,24 @@
1
1
  import { z } from "zod";
2
2
  import { AsyncActivityTokenNotFoundError } from "../../core/engine.js";
3
+ import {
4
+ DEFAULT_PENDING_ASYNC_ACTIVITY_LIMIT,
5
+ isPendingAsyncActivityCursor,
6
+ isPendingAsyncActivityCursorForWorkflow,
7
+ MAX_PENDING_ASYNC_ACTIVITY_CURSOR_LENGTH,
8
+ MAX_PENDING_ASYNC_ACTIVITY_LIMIT
9
+ } from "../../core/engine/async-activity-records.js";
3
10
  import { PayloadSizeExceededError } from "../../core/payload-size.js";
4
11
  import { raiseFault } from "../operation-catalog.js";
5
12
  import { defineOperation } from "../operation-registry.js";
6
13
  import { readRestJsonBody } from "../rest-body.js";
7
14
  import { invalidParamsFault, isOperationFault, shapeRestFault } from "./operation-helpers.js";
8
- const asyncActivityAccess = { kind: "public" }, httpAndJsonRpcTransports = {
15
+ const asyncActivityReadAccess = {
16
+ kind: "scoped",
17
+ scopes: { kind: "anyOf", scopes: ["workflows:read"] }
18
+ }, asyncActivityWriteAccess = {
19
+ kind: "scoped",
20
+ scopes: { kind: "anyOf", scopes: ["workflows:write"] }
21
+ }, httpAndJsonRpcTransports = {
9
22
  http: !0,
10
23
  jsonRpcHttp: !0,
11
24
  jsonRpcStdio: !0,
@@ -13,13 +26,56 @@ const asyncActivityAccess = { kind: "public" }, httpAndJsonRpcTransports = {
13
26
  }, completeAsyncActivityInput = z.object({
14
27
  token: z.string().min(1),
15
28
  result: z.unknown().optional()
16
- }), failAsyncActivityInput = z.object({
29
+ }), pendingAsyncActivityItemSchema = z.object({
30
+ token: z.string(),
31
+ operationId: z.string(),
32
+ activityName: z.string(),
33
+ step: z.number().int().nonnegative(),
34
+ attempt: z.number().int().positive(),
35
+ createdAt: z.number()
36
+ }).strict(), listPendingAsyncActivitiesInput = z.object({
37
+ workflowId: z.string().min(1),
38
+ limit: z.number().int().min(1).max(MAX_PENDING_ASYNC_ACTIVITY_LIMIT).default(DEFAULT_PENDING_ASYNC_ACTIVITY_LIMIT),
39
+ cursor: z.string().max(MAX_PENDING_ASYNC_ACTIVITY_CURSOR_LENGTH).refine(isPendingAsyncActivityCursor, { message: "Invalid cursor" }).optional()
40
+ }), listPendingAsyncActivitiesOutput = z.object({
41
+ items: z.array(pendingAsyncActivityItemSchema),
42
+ nextCursor: z.string().optional()
43
+ }).strict(), failAsyncActivityInput = z.object({
17
44
  token: z.string().min(1),
18
45
  error: z.object({
19
46
  message: z.string(),
20
47
  name: z.string().optional()
21
48
  })
22
49
  }), okOutput = z.object({ ok: z.literal(!0) });
50
+ export const listPendingAsyncActivitiesOperation = defineOperation({
51
+ name: "weft.workflows.activities.pending.list",
52
+ mcpExposable: !1,
53
+ summary: "List pending async activities for a workflow",
54
+ description: "Read a bounded, deterministic page of durable activity task tokens awaiting out-of-band completion. The cursor is opaque and scoped to the selected workflow. A listed token may be consumed concurrently, so a later completion can return NotFound.",
55
+ destructive: !1,
56
+ tags: ["Activities"],
57
+ inputSchema: listPendingAsyncActivitiesInput,
58
+ outputSchema: listPendingAsyncActivitiesOutput,
59
+ access: asyncActivityReadAccess,
60
+ producibleFaults: ["NotFound", "InvalidParams"],
61
+ transports: httpAndJsonRpcTransports,
62
+ unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
63
+ invoke: async ({ input, engine }) => {
64
+ const liveEngine = engine;
65
+ if (input.cursor !== void 0 && !isPendingAsyncActivityCursorForWorkflow(input.cursor, input.workflowId))
66
+ raiseFault(listPendingAsyncActivitiesOperation, invalidParamsFault("Cursor does not belong to this workflow."));
67
+ if (await liveEngine.get(input.workflowId) === null)
68
+ raiseFault(listPendingAsyncActivitiesOperation, {
69
+ code: "NotFound",
70
+ message: `Workflow "${input.workflowId}" not found`,
71
+ data: { resource: "workflow", identifier: input.workflowId }
72
+ });
73
+ return liveEngine.listPendingAsyncActivities(input.workflowId, {
74
+ limit: input.limit,
75
+ ...input.cursor === void 0 ? {} : { cursor: input.cursor }
76
+ });
77
+ }
78
+ });
23
79
  function errorFromFailInput(input) {
24
80
  const error = Error(input.error.message);
25
81
  if (input.error.name !== void 0)
@@ -46,7 +102,7 @@ export const completeAsyncActivityOperation = defineOperation({
46
102
  tags: ["Activities"],
47
103
  inputSchema: completeAsyncActivityInput,
48
104
  outputSchema: okOutput,
49
- access: asyncActivityAccess,
105
+ access: asyncActivityWriteAccess,
50
106
  producibleFaults: ["NotFound", "InvalidParams"],
51
107
  transports: httpAndJsonRpcTransports,
52
108
  unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
@@ -68,7 +124,7 @@ export const completeAsyncActivityOperation = defineOperation({
68
124
  tags: ["Activities"],
69
125
  inputSchema: failAsyncActivityInput,
70
126
  outputSchema: okOutput,
71
- access: asyncActivityAccess,
127
+ access: asyncActivityWriteAccess,
72
128
  producibleFaults: ["NotFound", "InvalidParams"],
73
129
  transports: httpAndJsonRpcTransports,
74
130
  unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
@@ -88,6 +144,34 @@ function shapeAsyncActivitySuccess(output) {
88
144
  headers: { "Content-Type": "application/json" }
89
145
  });
90
146
  }
147
+ function shapePendingAsyncActivitiesSuccess(output) {
148
+ return new Response(JSON.stringify(output), {
149
+ status: 200,
150
+ headers: { "Content-Type": "application/json" }
151
+ });
152
+ }
153
+ export const listPendingAsyncActivitiesRestBinding = {
154
+ method: "GET",
155
+ path: "/v1/workflows/:id/pending-async-activities",
156
+ pathParamNames: ["id"],
157
+ operationName: "weft.workflows.activities.pending.list",
158
+ inputSources: {
159
+ workflowId: { kind: "path", pathParam: "id" },
160
+ limit: { kind: "query", queryParam: "limit" },
161
+ cursor: { kind: "query", queryParam: "cursor" }
162
+ },
163
+ extractInput: async (request, pathParams) => {
164
+ const search = new URL(request.url).searchParams, limit = search.get("limit"), cursor = search.get("cursor");
165
+ return {
166
+ workflowId: pathParams.id ?? "",
167
+ ...limit === null ? {} : { limit: Number(limit) },
168
+ ...cursor === null ? {} : { cursor }
169
+ };
170
+ },
171
+ success: { kind: "json", status: 200 },
172
+ shapeSuccess: (output) => shapePendingAsyncActivitiesSuccess(output),
173
+ shapeFault: shapeRestFault
174
+ };
91
175
  async function readJsonObjectBody(request, context) {
92
176
  const body = await readRestJsonBody(request, context).catch((error) => {
93
177
  if (isOperationFault(error))
@@ -6,6 +6,9 @@ import type { RestInputContext } from '../rest-binding.ts';
6
6
  export declare const bulkListFilterInputSchema: z.ZodObject<{
7
7
  status: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<WorkflowStatus, WorkflowStatus>, z.ZodArray<z.ZodCustom<WorkflowStatus, WorkflowStatus>>]>>;
8
8
  type: z.ZodOptional<z.ZodString>;
9
+ scheduleId: z.ZodOptional<z.ZodString>;
10
+ parentWorkflowId: z.ZodOptional<z.ZodString>;
11
+ parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
9
12
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
13
  attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
14
  key: z.ZodString;
@@ -29,6 +29,9 @@ const workflowStatusSchema = z.custom((value) => typeof value === "string"), sea
29
29
  export const bulkListFilterInputSchema = z.object({
30
30
  status: z.union([workflowStatusSchema, z.array(workflowStatusSchema)]).optional(),
31
31
  type: z.string().optional(),
32
+ scheduleId: z.string().min(1).optional(),
33
+ parentWorkflowId: z.string().min(1).optional(),
34
+ parentWorkflowExecutionToken: z.string().min(1).optional(),
32
35
  tags: z.array(z.string()).optional(),
33
36
  attributes: z.array(attributeFilterSchema).optional(),
34
37
  limit: z.number().int().min(0).optional(),
@@ -117,12 +120,12 @@ function parseFilterStatus(value) {
117
120
  return value;
118
121
  throw Error('Field "filter.status" must be a string or an array of strings');
119
122
  }
120
- function parseOptionalFilterType(value) {
123
+ function parseOptionalFilterString(value, fieldName) {
121
124
  if (value === void 0)
122
125
  return;
123
126
  if (typeof value === "string")
124
127
  return value;
125
- throw Error('Field "filter.type" must be a string');
128
+ throw Error(`Field "filter.${fieldName}" must be a string`);
126
129
  }
127
130
  function parseOptionalFilterTags(value) {
128
131
  if (value === void 0)
@@ -143,10 +146,25 @@ const BULK_FILTER_DIMENSION_PARSERS = [
143
146
  filter.status = status;
144
147
  },
145
148
  (filter, record) => {
146
- const type = parseOptionalFilterType(record.type);
149
+ const type = parseOptionalFilterString(record.type, "type");
147
150
  if (type !== void 0)
148
151
  filter.type = type;
149
152
  },
153
+ (filter, record) => {
154
+ const scheduleId = parseOptionalFilterString(record.scheduleId, "scheduleId");
155
+ if (scheduleId !== void 0)
156
+ filter.scheduleId = scheduleId;
157
+ },
158
+ (filter, record) => {
159
+ const parentWorkflowId = parseOptionalFilterString(record.parentWorkflowId, "parentWorkflowId");
160
+ if (parentWorkflowId !== void 0)
161
+ filter.parentWorkflowId = parentWorkflowId;
162
+ },
163
+ (filter, record) => {
164
+ const parentWorkflowExecutionToken = parseOptionalFilterString(record.parentWorkflowExecutionToken, "parentWorkflowExecutionToken");
165
+ if (parentWorkflowExecutionToken !== void 0)
166
+ filter.parentWorkflowExecutionToken = parentWorkflowExecutionToken;
167
+ },
150
168
  (filter, record) => {
151
169
  const tags = parseOptionalFilterTags(record.tags);
152
170
  if (tags !== void 0)
@@ -272,6 +290,12 @@ function copyAttributeRangeBound(value, property) {
272
290
  return value;
273
291
  }
274
292
  function applyExtendedBulkFilterFields(filter, input) {
293
+ if (input.scheduleId !== void 0)
294
+ filter.scheduleId = input.scheduleId;
295
+ if (input.parentWorkflowId !== void 0)
296
+ filter.parentWorkflowId = input.parentWorkflowId;
297
+ if (input.parentWorkflowExecutionToken !== void 0)
298
+ filter.parentWorkflowExecutionToken = input.parentWorkflowExecutionToken;
275
299
  if (input.idPrefix !== void 0)
276
300
  filter.idPrefix = input.idPrefix;
277
301
  if (input.failureCategory !== void 0)
@@ -5,6 +5,9 @@ declare const bulkMutateWorkflowTagsInput: z.ZodObject<{
5
5
  filter: z.ZodOptional<z.ZodObject<{
6
6
  status: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<import("../../index.ts").WorkflowStatus, import("../../index.ts").WorkflowStatus>, z.ZodArray<z.ZodCustom<import("../../index.ts").WorkflowStatus, import("../../index.ts").WorkflowStatus>>]>>;
7
7
  type: z.ZodOptional<z.ZodString>;
8
+ scheduleId: z.ZodOptional<z.ZodString>;
9
+ parentWorkflowId: z.ZodOptional<z.ZodString>;
10
+ parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
8
11
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
9
12
  attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
10
13
  key: z.ZodString;
@@ -55,6 +58,9 @@ export declare const bulkMutateWorkflowTagsOperation: import("../operation-catal
55
58
  filter?: {
56
59
  status?: import("../../index.ts").WorkflowStatus | import("../../index.ts").WorkflowStatus[] | undefined;
57
60
  type?: string | undefined;
61
+ scheduleId?: string | undefined;
62
+ parentWorkflowId?: string | undefined;
63
+ parentWorkflowExecutionToken?: string | undefined;
58
64
  tags?: string[] | undefined;
59
65
  attributes?: {
60
66
  key: string;
@@ -4,6 +4,9 @@ import type { UnknownRestBinding } from '../rest-bindings.ts';
4
4
  declare const bulkSignalWorkflowsInput: z.ZodObject<{
5
5
  status: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<import("../../index.ts").WorkflowStatus, import("../../index.ts").WorkflowStatus>, z.ZodArray<z.ZodCustom<import("../../index.ts").WorkflowStatus, import("../../index.ts").WorkflowStatus>>]>>;
6
6
  type: z.ZodOptional<z.ZodString>;
7
+ scheduleId: z.ZodOptional<z.ZodString>;
8
+ parentWorkflowId: z.ZodOptional<z.ZodString>;
9
+ parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
7
10
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
11
  attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
9
12
  key: z.ZodString;
@@ -48,6 +51,9 @@ export declare const bulkSignalWorkflowsOperation: import("../operation-catalog.
48
51
  name: string;
49
52
  status?: import("../../index.ts").WorkflowStatus | import("../../index.ts").WorkflowStatus[] | undefined;
50
53
  type?: string | undefined;
54
+ scheduleId?: string | undefined;
55
+ parentWorkflowId?: string | undefined;
56
+ parentWorkflowExecutionToken?: string | undefined;
51
57
  tags?: string[] | undefined;
52
58
  attributes?: {
53
59
  key: string;
@@ -1,8 +1,7 @@
1
1
  import { z } from "zod";
2
- import { FAULT_CODE_TO_HTTP_STATUS } from "../operation-fault.js";
3
2
  import { defineOperation } from "../operation-registry.js";
4
3
  import { parseOptionalSequenceCursor } from "../sequence-cursor.js";
5
- import { invalidParamsFault, jsonErrorResponse } from "./operation-helpers.js";
4
+ import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
6
5
  import { createStoredChunkSSEStream, SSE_RESPONSE_HEADERS } from "./sse-stream.js";
7
6
  const getStreamChunksInput = z.object({
8
7
  workflowId: z.string().min(1),
@@ -33,11 +32,7 @@ export const getStreamChunksOperation = defineOperation({
33
32
  }
34
33
  });
35
34
  function shapeGetStreamChunksFault(fault) {
36
- if (fault.code === "InvalidParams")
37
- return jsonErrorResponse(fault.message, 400);
38
- if (fault.code === "EngineFailure")
39
- return jsonErrorResponse("Internal server error", 500);
40
- return jsonErrorResponse(fault.message, FAULT_CODE_TO_HTTP_STATUS[fault.code]);
35
+ return shapeRestFault(fault);
41
36
  }
42
37
  function shapeGetStreamChunksSuccess(output, request) {
43
38
  if ((request.headers.get("Accept") ?? "").includes("text/event-stream"))
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `weft.system.lease` operation + REST binding.
3
+ *
4
+ * Returns the serving engine process's last-known ownership-lease state. This
5
+ * is deliberately separate from anonymous `GET /v1/health`: load balancers need
6
+ * a stable liveness probe, while holder identifiers and fencing state are scoped
7
+ * operator diagnostics that require `system:read`.
8
+ *
9
+ * @module server/operations/get-system-lease
10
+ */
11
+ import { z } from 'zod';
12
+ import { type EngineLeaseHealth } from '../../core/engine.ts';
13
+ import type { UnknownRestBinding } from '../rest-bindings.ts';
14
+ declare const getSystemLeaseInput: z.ZodObject<{}, z.core.$strip>;
15
+ export type GetSystemLeaseInput = z.infer<typeof getSystemLeaseInput>;
16
+ export type GetSystemLeaseOutput = EngineLeaseHealth;
17
+ export declare const getSystemLeaseOperation: import("../operation-catalog.ts").OperationDefinition<Record<string, never>, EngineLeaseHealth, unknown>;
18
+ export declare const getSystemLeaseRestBinding: UnknownRestBinding;
19
+ export {};
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import { defineOperation } from "../operation-registry.js";
3
+ import { shapeRestFault } from "./operation-helpers.js";
4
+ const getSystemLeaseInput = z.object({}), getSystemLeaseOutput = z.object({
5
+ mode: z.enum(["none", "lease"]),
6
+ status: z.enum(["disabled", "healthy", "no-lease", "contested"]),
7
+ holdsLease: z.boolean(),
8
+ holderId: z.string().min(1).optional(),
9
+ heldSince: z.number().int().nonnegative().optional(),
10
+ expiresAt: z.number().int().nonnegative().optional(),
11
+ lastRenewedAt: z.number().int().nonnegative().optional(),
12
+ fencingEpoch: z.number().int().positive().safe().optional(),
13
+ lossReason: z.enum(["deposed", "renewal-unconfirmable"]).optional()
14
+ }).strict();
15
+ export const getSystemLeaseOperation = defineOperation({
16
+ name: "weft.system.lease",
17
+ mcpExposable: !1,
18
+ summary: "Get ownership-lease health for this engine process",
19
+ description: "Reports whether lease ownership is disabled, not yet held, healthy, or contested. Contested results preserve the confirmed deposed or renewal-unconfirmable reason.",
20
+ destructive: !1,
21
+ tags: ["System"],
22
+ inputSchema: getSystemLeaseInput,
23
+ outputSchema: getSystemLeaseOutput,
24
+ access: {
25
+ kind: "scoped",
26
+ scopes: { kind: "anyOf", scopes: ["system:read"] }
27
+ },
28
+ producibleFaults: [],
29
+ discoverable: !0,
30
+ transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
31
+ unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
32
+ invoke: async ({ engine }) => {
33
+ return engine.getLeaseHealth();
34
+ }
35
+ }), getSystemLeaseRestBinding = {
36
+ method: "GET",
37
+ path: "/v1/system/lease",
38
+ pathParamNames: [],
39
+ operationName: "weft.system.lease",
40
+ inputSources: {},
41
+ extractInput: async () => ({}),
42
+ success: { kind: "json", status: 200 },
43
+ shapeSuccess: (output) => new Response(JSON.stringify(output), {
44
+ status: 200,
45
+ headers: { "Content-Type": "application/json" }
46
+ }),
47
+ shapeFault: shapeRestFault
48
+ };
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import type { WorkflowFinalizerStatus, WorkflowScheduleProvenance } from '../../core/types.ts';
3
+ import type { UnknownRestBinding } from '../rest-bindings.ts';
4
+ declare const workflowObservabilityInput: z.ZodObject<{
5
+ workflowId: z.ZodString;
6
+ }, z.core.$strip>;
7
+ export type GetWorkflowObservabilityInput = z.infer<typeof workflowObservabilityInput>;
8
+ export type GetWorkflowScheduleProvenanceOutput = WorkflowScheduleProvenance | null;
9
+ export type GetWorkflowFinalizerOutput = WorkflowFinalizerStatus | null;
10
+ export declare const getWorkflowScheduleProvenanceOperation: import("../operation-catalog.ts").OperationDefinition<{
11
+ workflowId: string;
12
+ }, GetWorkflowScheduleProvenanceOutput, unknown>;
13
+ export declare const getWorkflowFinalizerOperation: import("../operation-catalog.ts").OperationDefinition<{
14
+ workflowId: string;
15
+ }, GetWorkflowFinalizerOutput, unknown>;
16
+ export declare const getWorkflowScheduleProvenanceRestBinding: UnknownRestBinding;
17
+ export declare const getWorkflowFinalizerRestBinding: UnknownRestBinding;
18
+ export declare const workflowObservabilityRestBindings: readonly [UnknownRestBinding, UnknownRestBinding];
19
+ export declare const workflowObservabilityOperations: readonly [import("../operation-catalog.ts").OperationDefinition<{
20
+ workflowId: string;
21
+ }, GetWorkflowScheduleProvenanceOutput, unknown>, import("../operation-catalog.ts").OperationDefinition<{
22
+ workflowId: string;
23
+ }, GetWorkflowFinalizerOutput, unknown>];
24
+ export {};
@@ -0,0 +1,80 @@
1
+ import { z } from "zod";
2
+ import { defineOperation } from "../operation-registry.js";
3
+ import { shapeRestFault } from "./operation-helpers.js";
4
+ const workflowObservabilityInput = z.object({
5
+ workflowId: z.string().min(1)
6
+ }), scheduleProvenanceOutput = z.object({
7
+ scheduleId: z.string(),
8
+ occurrence: z.number().optional()
9
+ }).nullable(), finalizerStatusOutput = z.discriminatedUnion("status", [
10
+ z.object({ status: z.literal("pending"), attempts: z.number().int().nonnegative() }),
11
+ z.object({
12
+ status: z.literal("running"),
13
+ attempts: z.number().int().positive(),
14
+ startedAt: z.number().nonnegative()
15
+ }),
16
+ z.object({
17
+ status: z.literal("succeeded"),
18
+ attempts: z.number().int().positive(),
19
+ completedAt: z.number().nonnegative()
20
+ }),
21
+ z.object({
22
+ status: z.literal("failed"),
23
+ attempts: z.number().int().nonnegative(),
24
+ failedAt: z.number().nonnegative(),
25
+ error: z.string()
26
+ })
27
+ ]).nullable();
28
+ export const getWorkflowScheduleProvenanceOperation = defineOperation({
29
+ name: "weft.workflows.scheduleprovenance.get",
30
+ mcpExposable: !1,
31
+ summary: "Get the schedule occurrence that launched a workflow",
32
+ description: "Read the durable schedule id and optional occurrence timestamp that launched a workflow. Returns null for runs that were not launched by a schedule or whose workflow history was purged.",
33
+ destructive: !1,
34
+ tags: ["Workflows"],
35
+ inputSchema: workflowObservabilityInput,
36
+ outputSchema: scheduleProvenanceOutput,
37
+ access: { kind: "public" },
38
+ producibleFaults: [],
39
+ transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
40
+ unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
41
+ invoke: async ({ input, engine }) => engine.getScheduleProvenance(input.workflowId)
42
+ }), getWorkflowFinalizerOperation = defineOperation({
43
+ name: "weft.workflows.finalizer.get",
44
+ mcpExposable: !1,
45
+ summary: "Get workflow finalizer progress and outcome",
46
+ description: "Read durable post-terminal finalizer progress or its succeeded or failed outcome. Returns null when the workflow did not record finalizer work.",
47
+ destructive: !1,
48
+ tags: ["Workflows"],
49
+ inputSchema: workflowObservabilityInput,
50
+ outputSchema: finalizerStatusOutput,
51
+ access: { kind: "public" },
52
+ producibleFaults: [],
53
+ transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
54
+ unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
55
+ invoke: async ({ input, engine }) => engine.getFinalizerStatus(input.workflowId)
56
+ }), getWorkflowScheduleProvenanceRestBinding = {
57
+ method: "GET",
58
+ path: "/v1/workflows/:id/schedule-provenance",
59
+ pathParamNames: ["id"],
60
+ operationName: "weft.workflows.scheduleprovenance.get",
61
+ inputSources: { workflowId: { kind: "path", pathParam: "id" } },
62
+ extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
63
+ success: { kind: "json", status: 200 },
64
+ shapeFault: shapeRestFault
65
+ }, getWorkflowFinalizerRestBinding = {
66
+ method: "GET",
67
+ path: "/v1/workflows/:id/finalizer",
68
+ pathParamNames: ["id"],
69
+ operationName: "weft.workflows.finalizer.get",
70
+ inputSources: { workflowId: { kind: "path", pathParam: "id" } },
71
+ extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
72
+ success: { kind: "json", status: 200 },
73
+ shapeFault: shapeRestFault
74
+ }, workflowObservabilityRestBindings = [
75
+ getWorkflowScheduleProvenanceRestBinding,
76
+ getWorkflowFinalizerRestBinding
77
+ ], workflowObservabilityOperations = [
78
+ getWorkflowScheduleProvenanceOperation,
79
+ getWorkflowFinalizerOperation
80
+ ];
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { jsonErrorResponse, shapeRestFault } from "./operation-helpers.js";
3
+ import { shapeRestFault } from "./operation-helpers.js";
4
4
  const getWorkflowResultInput = z.object({
5
5
  workflowId: z.string().min(1)
6
6
  }), getWorkflowResultOutput = z.unknown();
@@ -75,7 +75,7 @@ function shapeGetWorkflowResultSuccess(result) {
75
75
  }
76
76
  function shapeGetWorkflowResultFault(fault) {
77
77
  if (fault.code === "Timeout")
78
- return jsonErrorResponse("Timeout waiting for workflow result", 408);
78
+ return shapeRestFault(fault, { message: "Timeout waiting for workflow result", status: 408 });
79
79
  return shapeRestFault(fault);
80
80
  }
81
81
  export const getWorkflowResultRestBinding = {
@@ -2,8 +2,8 @@
2
2
  * `weft.workflows.get` operation + REST binding.
3
3
  *
4
4
  * Returns a workflow's state by id. REST response shape preserves the
5
- * historical format: 200 with the serialized `WorkflowState`, or a
6
- * 4xx/5xx with `{ error: <message> }` (a bare string), as emitted by
5
+ * historical format: 200 with the serialized `WorkflowState`, or a 4xx/5xx
6
+ * with the string `error` plus audited structured `data`, as emitted by
7
7
  * `shapeFault` below.
8
8
  *
9
9
  * @module server/operations/get-workflow
@@ -11,6 +11,18 @@ function parseType(params) {
11
11
  const type = params.get("type");
12
12
  return type === null ? void 0 : type;
13
13
  }
14
+ function parseScheduleId(params) {
15
+ const scheduleId = params.get("schedule_id");
16
+ return scheduleId === null ? void 0 : scheduleId;
17
+ }
18
+ function parseParentWorkflowId(params) {
19
+ const parentWorkflowId = params.get("parent_workflow_id");
20
+ return parentWorkflowId === null ? void 0 : parentWorkflowId;
21
+ }
22
+ function parseParentWorkflowExecutionToken(params) {
23
+ const parentWorkflowExecutionToken = params.get("parent_workflow_execution_token");
24
+ return parentWorkflowExecutionToken === null ? void 0 : parentWorkflowExecutionToken;
25
+ }
14
26
  function parseTags(params) {
15
27
  const tags = params.getAll("tag");
16
28
  return tags.length > 0 ? tags : void 0;
@@ -52,6 +64,9 @@ function parseExecutionDeadline(params) {
52
64
  const LIST_FILTER_QUERY_PARSERS = {
53
65
  status: parseStatus,
54
66
  type: parseType,
67
+ scheduleId: parseScheduleId,
68
+ parentWorkflowId: parseParentWorkflowId,
69
+ parentWorkflowExecutionToken: parseParentWorkflowExecutionToken,
55
70
  tags: parseTags,
56
71
  attributes: parseAttributes,
57
72
  idPrefix: parseIdPrefix,
@@ -4,6 +4,9 @@ import type { UnknownRestBinding } from '../rest-bindings.ts';
4
4
  declare const listWorkflowsInput: z.ZodObject<{
5
5
  status: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<WorkflowStatus, WorkflowStatus>, z.ZodArray<z.ZodCustom<WorkflowStatus, WorkflowStatus>>]>>;
6
6
  type: z.ZodOptional<z.ZodString>;
7
+ scheduleId: z.ZodOptional<z.ZodString>;
8
+ parentWorkflowId: z.ZodOptional<z.ZodString>;
9
+ parentWorkflowExecutionToken: z.ZodOptional<z.ZodString>;
7
10
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
11
  attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
9
12
  key: z.ZodString;
@@ -42,6 +45,9 @@ export type ListWorkflowsOutput = PaginatedResult<WorkflowSummary>;
42
45
  export declare const listWorkflowsOperation: import("../operation-catalog.ts").OperationDefinition<{
43
46
  status?: WorkflowStatus | WorkflowStatus[] | undefined;
44
47
  type?: string | undefined;
48
+ scheduleId?: string | undefined;
49
+ parentWorkflowId?: string | undefined;
50
+ parentWorkflowExecutionToken?: string | undefined;
45
51
  tags?: string[] | undefined;
46
52
  attributes?: {
47
53
  key: string;
@@ -7,7 +7,7 @@ import {
7
7
  import { coerceStartWorkflowTags } from "../../core/start-workflow-validation.js";
8
8
  import { defineOperation } from "../operation-registry.js";
9
9
  import { extractListFilterFromQuery } from "./list-filter-query-extractor.js";
10
- import { jsonErrorResponse, shapeRestFault } from "./operation-helpers.js";
10
+ import { shapeRestFault } from "./operation-helpers.js";
11
11
  const workflowStatusSchema = z.custom((value) => typeof value === "string"), failureCategorySchema = z.custom((value) => typeof value === "string"), searchAttributeValueSchema = z.custom((value) => {
12
12
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
13
13
  return !0;
@@ -27,6 +27,9 @@ const workflowStatusSchema = z.custom((value) => typeof value === "string"), fai
27
27
  }), listIncludeSchema = z.union([z.string(), z.array(z.string()).min(1)]).refine((value) => Array.isArray(value) ? value.every((entry) => entry === "failureCategory") : value === "failureCategory", { message: 'include must be "failureCategory"' }), listWorkflowsInput = z.object({
28
28
  status: z.union([workflowStatusSchema, z.array(workflowStatusSchema)]).optional(),
29
29
  type: z.string().optional(),
30
+ scheduleId: z.string().min(1).optional(),
31
+ parentWorkflowId: z.string().min(1).optional(),
32
+ parentWorkflowExecutionToken: z.string().min(1).optional(),
30
33
  tags: z.array(z.string()).optional(),
31
34
  attributes: z.array(attributeFilterSchema).optional(),
32
35
  limit: z.number().int().min(1).max(1000).optional(),
@@ -42,7 +45,7 @@ export const listWorkflowsOperation = defineOperation({
42
45
  name: "weft.workflows.list",
43
46
  mcpExposable: !1,
44
47
  summary: "List workflows",
45
- description: "List workflows visible to the caller, optionally filtered by status, type, tags, id prefix, failure category, and time range, with pagination via `limit`/`offset`. Read-only. Returns the matching workflow summaries in the engine default ordering.",
48
+ description: "List workflows visible to the caller, optionally filtered by status, type, originating schedule, direct parent run, tags, id prefix, failure category, and time range, with pagination via `limit`/`offset`. Read-only. Returns the matching workflow summaries in the engine default ordering.",
46
49
  destructive: !1,
47
50
  tags: ["Workflows"],
48
51
  inputSchema: listWorkflowsInput,
@@ -113,7 +116,7 @@ function shapeListWorkflowsSuccess(result) {
113
116
  }
114
117
  function shapeListWorkflowsFault(fault) {
115
118
  if (fault.code === "Unprocessable")
116
- return jsonErrorResponse(fault.message, 400);
119
+ return shapeRestFault(fault, { status: 400 });
117
120
  return shapeRestFault(fault);
118
121
  }
119
122
  export const listWorkflowsRestBinding = {
@@ -124,6 +127,12 @@ export const listWorkflowsRestBinding = {
124
127
  inputSources: {
125
128
  status: { kind: "query", queryParam: "status", repeating: !0 },
126
129
  type: { kind: "query", queryParam: "type" },
130
+ scheduleId: { kind: "query", queryParam: "schedule_id" },
131
+ parentWorkflowId: { kind: "query", queryParam: "parent_workflow_id" },
132
+ parentWorkflowExecutionToken: {
133
+ kind: "query",
134
+ queryParam: "parent_workflow_execution_token"
135
+ },
127
136
  tags: { kind: "query", queryParam: "tag", repeating: !0 },
128
137
  limit: { kind: "query", queryParam: "limit" },
129
138
  offset: { kind: "query", queryParam: "offset" },
@@ -1,13 +1,7 @@
1
- import { type WeftErrorCode } from '../../core/weft-error.ts';
2
- import { type OperationFault } from '../operation-fault.ts';
1
+ import type { WeftErrorCode } from '../../core/weft-error.ts';
2
+ import { type OperationFault, type RestFaultResponseOptions } from '../operation-fault.ts';
3
3
  /** Type guard distinguishing an `OperationFault` from a value type. */
4
4
  export declare function isOperationFault(value: unknown): value is OperationFault;
5
- /**
6
- * Build a JSON error response with the flat shape `{ error: <message> }` and
7
- * `Content-Type: application/json`. Used by per-operation `shapeFault`
8
- * implementations that need ad-hoc status codes outside the canonical map.
9
- */
10
- export declare function jsonErrorResponse(message: string, status: number): Response;
11
5
  /**
12
6
  * Construct an `InvalidParams` fault with the `{ issues: [] }` data
13
7
  * shape. This is the canonical 400-class fault for caller-input validation
@@ -21,16 +15,13 @@ export declare function jsonErrorResponse(message: string, status: number): Resp
21
15
  */
22
16
  export declare function invalidParamsFault(message: string, weftCode?: WeftErrorCode): OperationFault;
23
17
  /**
24
- * Default REST fault shaper: masks `EngineFailure` to a generic
25
- * `"Internal server error"` 500; other faults map by `FAULT_CODE_TO_HTTP_STATUS`.
26
- * REST-only — JSON-RPC transports receive unmasked faults.
18
+ * Default REST fault shaper. Delegates to the centralized, exhaustively
19
+ * audited REST projection so direct and per-operation bindings cannot drift.
20
+ * REST-only — JSON-RPC transports receive their distinct operation fault data.
27
21
  *
28
22
  * When the fault carries a fine-grained `data.weftCode` (set only at sites that
29
- * hold a typed `WeftError`, e.g. `WorkflowNotFoundError` /
30
- * `WorkflowNotRegisteredError`), it is emitted as a top-level `weftCode` sibling
31
- * of the flat `{ error }` body so REST clients can branch transport-uniformly
32
- * via `isWeftFault`. The body's `error` stays a plain string, so the new field
33
- * is a sibling rather than nested. Faults without a `weftCode` keep their exact
34
- * `{ error }` shape, and `EngineFailure` stays masked (it carries no weftCode).
23
+ * hold a typed `WeftError`), it remains a top-level `weftCode` sibling. Safe
24
+ * structured fields are added under `data`; fields outside the per-code
25
+ * allowlist are withheld. `EngineFailure` stays byte-identically masked.
35
26
  */
36
- export declare function shapeRestFault(fault: OperationFault): Response;
27
+ export declare function shapeRestFault(fault: OperationFault, options?: RestFaultResponseOptions): Response;