@lostgradient/weft 0.15.0 → 0.17.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 (147) hide show
  1. package/README.md +1 -1
  2. package/dist/alerting/alert-manager.d.ts +5 -3
  3. package/dist/alerting/alert-manager.js +26 -5
  4. package/dist/alerting/index.d.ts +1 -1
  5. package/dist/alerting/types.d.ts +17 -13
  6. package/dist/alerting/types.js +5 -0
  7. package/dist/cli/api.js +5 -19
  8. package/dist/cli/console.d.ts +12 -0
  9. package/dist/cli/console.js +62 -0
  10. package/dist/cli/generated/operation-catalog.snapshot.json +71 -0
  11. package/dist/cli/generated/operation-client.generated.d.ts +15 -2
  12. package/dist/cli/generated/operation-client.generated.js +2 -0
  13. package/dist/cli/help-text.d.ts +1 -1
  14. package/dist/cli/help-text.js +1 -0
  15. package/dist/cli/index.d.ts +1 -0
  16. package/dist/cli/index.js +1 -0
  17. package/dist/cli/json-input.d.ts +20 -0
  18. package/dist/cli/json-input.js +33 -0
  19. package/dist/cli/parse-arguments.js +2 -0
  20. package/dist/cli/schedule.js +7 -9
  21. package/dist/cli/types.d.ts +1 -0
  22. package/dist/cli/workflow-commands.js +5 -25
  23. package/dist/cli-main.js +4 -2
  24. package/dist/core/engine/disposal.js +7 -0
  25. package/dist/core/engine/engine-runtime-helpers.d.ts +3 -1
  26. package/dist/core/engine/engine-runtime-helpers.js +2 -2
  27. package/dist/core/engine/errors.d.ts +20 -0
  28. package/dist/core/engine/errors.js +8 -0
  29. package/dist/core/engine/index.d.ts +39 -14
  30. package/dist/core/engine/index.js +84 -9
  31. package/dist/core/engine/inline-launch-queue.d.ts +6 -2
  32. package/dist/core/engine/inline-launch-queue.js +41 -6
  33. package/dist/core/engine/internals.d.ts +2 -0
  34. package/dist/core/engine/lease-manager.d.ts +3 -2
  35. package/dist/core/engine/lease-manager.js +7 -3
  36. package/dist/core/engine/operations-time.js +6 -0
  37. package/dist/core/execution-strategy.d.ts +8 -0
  38. package/dist/core/inline-execution-strategy.d.ts +1 -0
  39. package/dist/core/inline-execution-strategy.js +33 -20
  40. package/dist/core/weft-error.d.ts +1 -1
  41. package/dist/core/weft-error.js +1 -0
  42. package/dist/core/worker-execution-strategy.d.ts +2 -0
  43. package/dist/core/worker-execution-strategy.js +7 -2
  44. package/dist/core/worker-turn-watchdog.d.ts +4 -1
  45. package/dist/core/worker-turn-watchdog.js +9 -4
  46. package/dist/diagnostics/recommendations.js +1 -9
  47. package/dist/http.js +2 -2
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.js +1 -0
  50. package/dist/indexeddb.js +1 -1
  51. package/dist/json-schema.js +1 -1
  52. package/dist/mcp/tools.js +1 -3
  53. package/dist/server/authorization-scope.d.ts +1 -1
  54. package/dist/server/authorization-scope.js +0 -2
  55. package/dist/server/dashboard-assets.d.ts +37 -0
  56. package/dist/server/dashboard-assets.js +209 -0
  57. package/dist/server/index.d.ts +10 -1
  58. package/dist/server/index.js +11 -2
  59. package/dist/server/interactive-operations.js +1 -0
  60. package/dist/server/operations/aggregate-workflows.js +0 -7
  61. package/dist/server/operations/async-activity.js +5 -24
  62. package/dist/server/operations/bulk-cancel-workflows.js +3 -8
  63. package/dist/server/operations/bulk-delete-workflows.js +3 -8
  64. package/dist/server/operations/bulk-mutate-workflow-tags.js +3 -8
  65. package/dist/server/operations/bulk-operation-helpers.d.ts +2 -10
  66. package/dist/server/operations/bulk-operation-helpers.js +0 -6
  67. package/dist/server/operations/bulk-retry-failed-workflows.js +3 -8
  68. package/dist/server/operations/bulk-signal-workflows.js +3 -8
  69. package/dist/server/operations/cancel-schedule.js +1 -3
  70. package/dist/server/operations/cancel-workflow.js +1 -3
  71. package/dist/server/operations/create-schedule.js +21 -49
  72. package/dist/server/operations/fork-workflow.js +2 -3
  73. package/dist/server/operations/get-checkpoint-at.js +1 -6
  74. package/dist/server/operations/get-registry.js +1 -7
  75. package/dist/server/operations/get-retention-overview.js +2 -15
  76. package/dist/server/operations/get-review.js +2 -15
  77. package/dist/server/operations/get-schedule.js +2 -8
  78. package/dist/server/operations/get-stream-chunks.js +2 -6
  79. package/dist/server/operations/get-system-lease.js +1 -7
  80. package/dist/server/operations/get-system-metrics.js +0 -4
  81. package/dist/server/operations/get-task-diagnostics.js +2 -13
  82. package/dist/server/operations/get-update-result.js +1 -6
  83. package/dist/server/operations/get-workflow-attributes.js +2 -15
  84. package/dist/server/operations/get-workflow-events.js +2 -15
  85. package/dist/server/operations/get-workflow-observability.js +2 -5
  86. package/dist/server/operations/get-workflow-result.js +0 -7
  87. package/dist/server/operations/get-workflow-timeline.js +1 -6
  88. package/dist/server/operations/get-workflow.d.ts +3 -6
  89. package/dist/server/operations/get-workflow.js +2 -12
  90. package/dist/server/operations/list-alerts.d.ts +29 -0
  91. package/dist/server/operations/list-alerts.js +47 -0
  92. package/dist/server/operations/list-checkpoints.js +1 -6
  93. package/dist/server/operations/list-reviews.js +0 -7
  94. package/dist/server/operations/list-schedules.js +3 -8
  95. package/dist/server/operations/list-task-queues.js +0 -4
  96. package/dist/server/operations/list-workers.js +0 -4
  97. package/dist/server/operations/list-workflows.js +0 -7
  98. package/dist/server/operations/pause-schedule.js +1 -3
  99. package/dist/server/operations/purge-workflows.js +2 -5
  100. package/dist/server/operations/query-workflow.js +4 -15
  101. package/dist/server/operations/replay-workflow.js +2 -6
  102. package/dist/server/operations/resume-schedule.js +1 -3
  103. package/dist/server/operations/resume-workflow.js +1 -3
  104. package/dist/server/operations/schedule-faults.d.ts +9 -1
  105. package/dist/server/operations/schedule-faults.js +51 -0
  106. package/dist/server/operations/set-workflow-attributes.js +3 -15
  107. package/dist/server/operations/signal-workflow.js +3 -12
  108. package/dist/server/operations/single-workflow-tag-mutation.js +0 -7
  109. package/dist/server/operations/start-or-signal-workflow.js +2 -3
  110. package/dist/server/operations/start-workflow.js +2 -3
  111. package/dist/server/operations/storage-capabilities.js +1 -3
  112. package/dist/server/operations/storage.js +7 -13
  113. package/dist/server/operations/submit-review-decision.js +3 -12
  114. package/dist/server/operations/suspend-workflow.js +1 -3
  115. package/dist/server/operations/timeout-workflow.js +1 -3
  116. package/dist/server/operations/update-schedule.js +7 -56
  117. package/dist/server/operations/update-workflow.js +2 -3
  118. package/dist/server/operations/worker-drain.js +0 -8
  119. package/dist/server/rest-binding.d.ts +3 -2
  120. package/dist/server/rest-bindings.js +3 -0
  121. package/dist/server/route-model.d.ts +2 -0
  122. package/dist/server/route-model.js +1 -1
  123. package/dist/server/runtime/task-reconciliation.d.ts +10 -1
  124. package/dist/server/runtime/task-reconciliation.js +26 -2
  125. package/dist/server/serve-internals.js +12 -6
  126. package/dist/service-worker/index.d.ts +4 -1
  127. package/dist/service-worker/index.js +2 -2
  128. package/dist/service-worker/setup.d.ts +20 -0
  129. package/dist/service-worker/setup.js +5 -5
  130. package/dist/storage/bun-sql.js +13 -31
  131. package/dist/storage/indexeddb.js +28 -48
  132. package/dist/storage/lmdb.js +1 -1
  133. package/dist/storage/memory.js +1 -1
  134. package/dist/storage/neon.js +2 -2
  135. package/dist/storage/postgres.js +2 -2
  136. package/dist/storage/resolve.js +1 -1
  137. package/dist/storage/scoped-storage.js +1 -1
  138. package/dist/storage/testing.d.ts +6 -3
  139. package/dist/storage/testing.js +1 -1
  140. package/dist/storage/turso.js +2 -2
  141. package/dist/version.d.ts +1 -1
  142. package/dist/version.js +1 -1
  143. package/dist/web-extension.js +1 -1
  144. package/dist/worker/protocol-schemas.d.ts +2 -2
  145. package/dist/worker/protocol-schemas.js +2 -2
  146. package/dist/worker/protocol.js +1 -1
  147. package/package.json +5 -1
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
3
  import { readRestTextBody } from "../rest-body.js";
4
- import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
4
+ import { invalidParamsFault } from "./operation-helpers.js";
5
5
  const forkWorkflowInput = z.object({
6
6
  workflowId: z.string().min(1),
7
7
  fromStep: z.unknown().optional()
@@ -84,6 +84,5 @@ export const forkWorkflowOperation = defineOperation({
84
84
  fromStep: record.fromStep
85
85
  };
86
86
  },
87
- success: { kind: "json", status: 201 },
88
- shapeFault: shapeRestFault
87
+ success: { kind: "json", status: 201 }
89
88
  };
@@ -1,7 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { negotiatedResponse } from "../handler/response-helpers.js";
3
3
  import { defineOperation } from "../operation-registry.js";
4
- import { shapeRestFault } from "./operation-helpers.js";
5
4
  const getCheckpointAtInput = z.object({
6
5
  workflowId: z.string().min(1),
7
6
  step: z.number().int().nonnegative()
@@ -32,9 +31,6 @@ export const getCheckpointAtOperation = defineOperation({
32
31
  function shapeGetCheckpointAtSuccess(result, request) {
33
32
  return negotiatedResponse(request, result, 200);
34
33
  }
35
- function shapeGetCheckpointAtFault(fault) {
36
- return shapeRestFault(fault);
37
- }
38
34
  export const getCheckpointAtRestBinding = {
39
35
  method: "GET",
40
36
  path: "/v1/workflows/:id/checkpoints/:step",
@@ -69,6 +65,5 @@ export const getCheckpointAtRestBinding = {
69
65
  };
70
66
  },
71
67
  success: { kind: "json", status: 200 },
72
- shapeSuccess: (output, request) => shapeGetCheckpointAtSuccess(output, request),
73
- shapeFault: shapeGetCheckpointAtFault
68
+ shapeSuccess: (output, request) => shapeGetCheckpointAtSuccess(output, request)
74
69
  };
@@ -4,7 +4,6 @@ import {
4
4
  RegistrySchemaConversionError
5
5
  } from "../../core/registry-snapshot.js";
6
6
  import { defineOperation } from "../operation-registry.js";
7
- import { shapeRestFault } from "./operation-helpers.js";
8
7
  const getRegistryInput = z.object({}), objectValue = z.unknown().refine((value) => typeof value === "object" && value !== null && !Array.isArray(value), {
9
8
  message: "expected an object"
10
9
  }), getRegistryOutput = z.object({
@@ -47,10 +46,5 @@ export const getRegistryOperation = defineOperation({
47
46
  operationName: "weft.system.registry",
48
47
  inputSources: {},
49
48
  extractInput: async () => ({}),
50
- success: { kind: "json", status: 200 },
51
- shapeSuccess: (output) => new Response(JSON.stringify(output), {
52
- status: 200,
53
- headers: { "Content-Type": "application/json" }
54
- }),
55
- shapeFault: shapeRestFault
49
+ success: { kind: "json", status: 200 }
56
50
  };
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const getRetentionOverviewInput = z.object({}), getRetentionOverviewOutput = z.unknown();
5
4
  export const getRetentionOverviewOperation = defineOperation({
6
5
  name: "weft.retention.get",
@@ -16,24 +15,12 @@ export const getRetentionOverviewOperation = defineOperation({
16
15
  invoke: async ({ engine }) => {
17
16
  return engine.getRetentionOverview();
18
17
  }
19
- });
20
- function shapeGetRetentionOverviewSuccess(result) {
21
- return new Response(JSON.stringify(result), {
22
- status: 200,
23
- headers: { "Content-Type": "application/json" }
24
- });
25
- }
26
- function shapeGetRetentionOverviewFault(fault) {
27
- return shapeRestFault(fault);
28
- }
29
- export const getRetentionOverviewRestBinding = {
18
+ }), getRetentionOverviewRestBinding = {
30
19
  method: "GET",
31
20
  path: "/v1/retention",
32
21
  pathParamNames: [],
33
22
  operationName: "weft.retention.get",
34
23
  inputSources: {},
35
24
  extractInput: async () => ({}),
36
- success: { kind: "json", status: 200 },
37
- shapeSuccess: (output) => shapeGetRetentionOverviewSuccess(output),
38
- shapeFault: shapeGetRetentionOverviewFault
25
+ success: { kind: "json", status: 200 }
39
26
  };
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const getReviewInput = z.object({
5
4
  workflowId: z.string().min(1),
6
5
  reviewId: z.string().min(1)
@@ -28,17 +27,7 @@ export const getReviewOperation = defineOperation({
28
27
  };
29
28
  return review;
30
29
  }
31
- });
32
- function shapeGetReviewSuccess(result) {
33
- return new Response(JSON.stringify(result), {
34
- status: 200,
35
- headers: { "Content-Type": "application/json" }
36
- });
37
- }
38
- function shapeGetReviewFault(fault) {
39
- return shapeRestFault(fault);
40
- }
41
- export const getReviewRestBinding = {
30
+ }), getReviewRestBinding = {
42
31
  method: "GET",
43
32
  path: "/v1/workflows/:id/review/:reviewId",
44
33
  pathParamNames: ["id", "reviewId"],
@@ -51,7 +40,5 @@ export const getReviewRestBinding = {
51
40
  workflowId: pathParams.id ?? "",
52
41
  reviewId: pathParams.reviewId ?? ""
53
42
  }),
54
- success: { kind: "json", status: 200 },
55
- shapeSuccess: (output) => shapeGetReviewSuccess(output),
56
- shapeFault: shapeGetReviewFault
43
+ success: { kind: "json", status: 200 }
57
44
  };
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const getScheduleInput = z.object({
5
4
  scheduleId: z.string().min(1)
6
5
  }), getScheduleOutput = z.unknown();
@@ -28,11 +27,7 @@ export const getScheduleOperation = defineOperation({
28
27
  };
29
28
  return schedule;
30
29
  }
31
- });
32
- function shapeGetScheduleFault(fault) {
33
- return shapeRestFault(fault);
34
- }
35
- export const getScheduleRestBinding = {
30
+ }), getScheduleRestBinding = {
36
31
  method: "GET",
37
32
  path: "/v1/schedules/:id",
38
33
  pathParamNames: ["id"],
@@ -43,6 +38,5 @@ export const getScheduleRestBinding = {
43
38
  extractInput: async (_request, pathParams) => ({
44
39
  scheduleId: pathParams.id ?? ""
45
40
  }),
46
- success: { kind: "json", status: 200 },
47
- shapeFault: shapeGetScheduleFault
41
+ success: { kind: "json", status: 200 }
48
42
  };
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
3
  import { parseOptionalSequenceCursor } from "../sequence-cursor.js";
4
- import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
4
+ import { invalidParamsFault } from "./operation-helpers.js";
5
5
  import { createStoredChunkSSEStream, SSE_RESPONSE_HEADERS } from "./sse-stream.js";
6
6
  const getStreamChunksInput = z.object({
7
7
  workflowId: z.string().min(1),
@@ -31,9 +31,6 @@ export const getStreamChunksOperation = defineOperation({
31
31
  return { chunks: after !== void 0 ? await e.getStreamChunks(input.workflowId, input.key, { after }) : await e.getStreamChunks(input.workflowId, input.key) };
32
32
  }
33
33
  });
34
- function shapeGetStreamChunksFault(fault) {
35
- return shapeRestFault(fault);
36
- }
37
34
  function shapeGetStreamChunksSuccess(output, request) {
38
35
  if ((request.headers.get("Accept") ?? "").includes("text/event-stream"))
39
36
  return new Response(createStoredChunkSSEStream(output.chunks, (chunk) => JSON.stringify({ sequence: chunk.sequence, value: chunk.value })), { status: 200, headers: SSE_RESPONSE_HEADERS });
@@ -61,6 +58,5 @@ export const getStreamChunksRestBinding = {
61
58
  };
62
59
  },
63
60
  success: { kind: "streaming", mediaType: "text/event-stream" },
64
- shapeSuccess: shapeGetStreamChunksSuccess,
65
- shapeFault: shapeGetStreamChunksFault
61
+ shapeSuccess: shapeGetStreamChunksSuccess
66
62
  };
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const getSystemLeaseInput = z.object({}), getSystemLeaseOutput = z.object({
5
4
  mode: z.enum(["none", "lease"]),
6
5
  status: z.enum(["disabled", "healthy", "no-lease", "contested"]),
@@ -39,10 +38,5 @@ export const getSystemLeaseOperation = defineOperation({
39
38
  operationName: "weft.system.lease",
40
39
  inputSources: {},
41
40
  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
41
+ success: { kind: "json", status: 200 }
48
42
  };
@@ -34,10 +34,6 @@ export function createGetSystemMetricsRestBinding() {
34
34
  inputSources: {},
35
35
  extractInput: async () => ({}),
36
36
  success: { kind: "json", status: 200 },
37
- shapeSuccess: (output) => new Response(JSON.stringify(output), {
38
- status: 200,
39
- headers: { "Content-Type": "application/json" }
40
- }),
41
37
  shapeFault: shapeOperationFaultAsJson
42
38
  };
43
39
  }
@@ -12,7 +12,6 @@ import {
12
12
  isQueuedRecord,
13
13
  isResolvedRecord
14
14
  } from "../task-state.js";
15
- import { shapeRestFault } from "./operation-helpers.js";
16
15
  const DEFAULT_STALE_QUEUED_AFTER_MS = 60000, DEFAULT_STALE_HEARTBEAT_AFTER_MS = 60000, DEFAULT_RETRY_STORM_MINIMUM_ATTEMPTS = 3, DEFAULT_LIMIT = 50, MAX_LIMIT = 200, RESOLVED_HISTORY_SCAN_LIMIT = 1000, taskDiagnosticKindSchema = z.enum([
17
16
  "stuck-queued",
18
17
  "stale-inflight",
@@ -408,12 +407,7 @@ export const getTaskDiagnosticsRestBinding = {
408
407
  limit: parseOptionalNumber(url.searchParams.get("limit"))
409
408
  };
410
409
  },
411
- success: { kind: "json", status: 200 },
412
- shapeSuccess: (output) => new Response(JSON.stringify(output), {
413
- status: 200,
414
- headers: { "Content-Type": "application/json" }
415
- }),
416
- shapeFault: shapeRestFault
410
+ success: { kind: "json", status: 200 }
417
411
  }, clearTaskDeadLetterRestBinding = {
418
412
  method: "DELETE",
419
413
  path: "/v1/tasks/diagnostics/dead-letter/:operationId",
@@ -425,10 +419,5 @@ export const getTaskDiagnosticsRestBinding = {
425
419
  extractInput: async (_request, pathParams) => ({
426
420
  operationId: pathParams.operationId ?? ""
427
421
  }),
428
- success: { kind: "json", status: 200 },
429
- shapeSuccess: (output) => new Response(JSON.stringify(output), {
430
- status: 200,
431
- headers: { "Content-Type": "application/json" }
432
- }),
433
- shapeFault: shapeRestFault
422
+ success: { kind: "json", status: 200 }
434
423
  };
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const getUpdateResultInput = z.object({
5
4
  updateId: z.string().min(1)
6
5
  }), getUpdateResultOutput = z.unknown();
@@ -37,9 +36,6 @@ function shapeGetUpdateResultSuccess(result) {
37
36
  headers: { "Content-Type": "application/json" }
38
37
  });
39
38
  }
40
- function shapeGetUpdateResultFault(fault) {
41
- return shapeRestFault(fault);
42
- }
43
39
  export const getUpdateResultRestBinding = {
44
40
  method: "GET",
45
41
  path: "/v1/updates/:updateId",
@@ -50,6 +46,5 @@ export const getUpdateResultRestBinding = {
50
46
  },
51
47
  extractInput: async (_request, pathParams) => ({ updateId: pathParams.updateId ?? "" }),
52
48
  success: { kind: "json", status: 200 },
53
- shapeSuccess: (output) => shapeGetUpdateResultSuccess(output),
54
- shapeFault: shapeGetUpdateResultFault
49
+ shapeSuccess: (output) => shapeGetUpdateResultSuccess(output)
55
50
  };
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const getWorkflowAttributesInput = z.object({
5
4
  workflowId: z.string().min(1)
6
5
  }), getWorkflowAttributesOutput = z.unknown();
@@ -26,17 +25,7 @@ export const getWorkflowAttributesOperation = defineOperation({
26
25
  };
27
26
  return attributes;
28
27
  }
29
- });
30
- function shapeGetWorkflowAttributesSuccess(result) {
31
- return new Response(JSON.stringify(result), {
32
- status: 200,
33
- headers: { "Content-Type": "application/json" }
34
- });
35
- }
36
- function shapeGetWorkflowAttributesFault(fault) {
37
- return shapeRestFault(fault);
38
- }
39
- export const getWorkflowAttributesRestBinding = {
28
+ }), getWorkflowAttributesRestBinding = {
40
29
  method: "GET",
41
30
  path: "/v1/workflows/:id/attributes",
42
31
  pathParamNames: ["id"],
@@ -45,7 +34,5 @@ export const getWorkflowAttributesRestBinding = {
45
34
  workflowId: { kind: "path", pathParam: "id" }
46
35
  },
47
36
  extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
48
- success: { kind: "json", status: 200 },
49
- shapeSuccess: (output) => shapeGetWorkflowAttributesSuccess(output),
50
- shapeFault: shapeGetWorkflowAttributesFault
37
+ success: { kind: "json", status: 200 }
51
38
  };
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const getWorkflowEventsInput = z.object({
5
4
  workflowId: z.string().min(1)
6
5
  }), getWorkflowEventsOutput = z.unknown();
@@ -26,17 +25,7 @@ export const getWorkflowEventsOperation = defineOperation({
26
25
  };
27
26
  return { events: await e.getEvents(input.workflowId) };
28
27
  }
29
- });
30
- function shapeGetWorkflowEventsSuccess(result) {
31
- return new Response(JSON.stringify(result), {
32
- status: 200,
33
- headers: { "Content-Type": "application/json" }
34
- });
35
- }
36
- function shapeGetWorkflowEventsFault(fault) {
37
- return shapeRestFault(fault);
38
- }
39
- export const getWorkflowEventsRestBinding = {
28
+ }), getWorkflowEventsRestBinding = {
40
29
  method: "GET",
41
30
  path: "/v1/workflows/:id/events",
42
31
  pathParamNames: ["id"],
@@ -45,7 +34,5 @@ export const getWorkflowEventsRestBinding = {
45
34
  workflowId: { kind: "path", pathParam: "id" }
46
35
  },
47
36
  extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
48
- success: { kind: "json", status: 200 },
49
- shapeSuccess: (output) => shapeGetWorkflowEventsSuccess(output),
50
- shapeFault: shapeGetWorkflowEventsFault
37
+ success: { kind: "json", status: 200 }
51
38
  };
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const workflowObservabilityInput = z.object({
5
4
  workflowId: z.string().min(1)
6
5
  }), scheduleProvenanceOutput = z.object({
@@ -60,8 +59,7 @@ export const getWorkflowScheduleProvenanceOperation = defineOperation({
60
59
  operationName: "weft.workflows.scheduleprovenance.get",
61
60
  inputSources: { workflowId: { kind: "path", pathParam: "id" } },
62
61
  extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
63
- success: { kind: "json", status: 200 },
64
- shapeFault: shapeRestFault
62
+ success: { kind: "json", status: 200 }
65
63
  }, getWorkflowFinalizerRestBinding = {
66
64
  method: "GET",
67
65
  path: "/v1/workflows/:id/finalizer",
@@ -69,8 +67,7 @@ export const getWorkflowScheduleProvenanceOperation = defineOperation({
69
67
  operationName: "weft.workflows.finalizer.get",
70
68
  inputSources: { workflowId: { kind: "path", pathParam: "id" } },
71
69
  extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
72
- success: { kind: "json", status: 200 },
73
- shapeFault: shapeRestFault
70
+ success: { kind: "json", status: 200 }
74
71
  }, workflowObservabilityRestBindings = [
75
72
  getWorkflowScheduleProvenanceRestBinding,
76
73
  getWorkflowFinalizerRestBinding
@@ -67,12 +67,6 @@ export const getWorkflowResultOperation = defineOperation({
67
67
  }
68
68
  }
69
69
  });
70
- function shapeGetWorkflowResultSuccess(result) {
71
- return new Response(JSON.stringify(result), {
72
- status: 200,
73
- headers: { "Content-Type": "application/json" }
74
- });
75
- }
76
70
  function shapeGetWorkflowResultFault(fault) {
77
71
  if (fault.code === "Timeout")
78
72
  return shapeRestFault(fault, { message: "Timeout waiting for workflow result", status: 408 });
@@ -88,6 +82,5 @@ export const getWorkflowResultRestBinding = {
88
82
  },
89
83
  extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
90
84
  success: { kind: "json", status: 200 },
91
- shapeSuccess: (output) => shapeGetWorkflowResultSuccess(output),
92
85
  shapeFault: shapeGetWorkflowResultFault
93
86
  };
@@ -1,7 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { negotiatedResponse } from "../handler/response-helpers.js";
3
3
  import { defineOperation } from "../operation-registry.js";
4
- import { shapeRestFault } from "./operation-helpers.js";
5
4
  const getWorkflowTimelineInput = z.object({
6
5
  workflowId: z.string().min(1)
7
6
  }), getWorkflowTimelineOutput = z.unknown();
@@ -31,9 +30,6 @@ export const getWorkflowTimelineOperation = defineOperation({
31
30
  function shapeGetWorkflowTimelineSuccess(result, request) {
32
31
  return negotiatedResponse(request, result, 200);
33
32
  }
34
- function shapeGetWorkflowTimelineFault(fault) {
35
- return shapeRestFault(fault);
36
- }
37
33
  export const getWorkflowTimelineRestBinding = {
38
34
  method: "GET",
39
35
  path: "/v1/workflows/:id/timeline",
@@ -46,6 +42,5 @@ export const getWorkflowTimelineRestBinding = {
46
42
  workflowId: pathParams.id ?? ""
47
43
  }),
48
44
  success: { kind: "json", status: 200 },
49
- shapeSuccess: (output, request) => shapeGetWorkflowTimelineSuccess(output, request),
50
- shapeFault: shapeGetWorkflowTimelineFault
45
+ shapeSuccess: (output, request) => shapeGetWorkflowTimelineSuccess(output, request)
51
46
  };
@@ -3,8 +3,7 @@
3
3
  *
4
4
  * Returns a workflow's state by id. REST response shape preserves the
5
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
- * `shapeFault` below.
6
+ * with the string `error` plus audited structured `data`.
8
7
  *
9
8
  * @module server/operations/get-workflow
10
9
  */
@@ -27,10 +26,8 @@ export declare const getWorkflowOperation: import("../operation-catalog.ts").Ope
27
26
  * Typed as `UnknownRestBinding` at the module boundary so the router's
28
27
  * heterogeneous `ReadonlyArray<UnknownRestBinding>` storage doesn't
29
28
  * run into `exactOptionalPropertyTypes` contravariance on
30
- * `shapeSuccess`. The concrete `GetWorkflowOutput` typing remains at
31
- * the `shapeGetWorkflowSuccess` function signature above — that's
32
- * where real type checking matters (did the output come out wrong?).
33
- * The router itself only sees a shape-uniform `RestBinding<any, any>`.
29
+ * the binding shape. The router itself only sees a shape-uniform
30
+ * `RestBinding<any, any>`.
34
31
  */
35
32
  export declare const getWorkflowRestBinding: UnknownRestBinding;
36
33
  export {};
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { shapeRestFault } from "./operation-helpers.js";
4
3
  const getWorkflowInput = z.object({
5
4
  workflowId: z.string().min(1)
6
5
  }), getWorkflowOutput = z.unknown();
@@ -27,14 +26,7 @@ export const getWorkflowOperation = defineOperation({
27
26
  };
28
27
  return state;
29
28
  }
30
- });
31
- function shapeGetWorkflowSuccess(state) {
32
- return new Response(JSON.stringify(state), {
33
- status: 200,
34
- headers: { "Content-Type": "application/json" }
35
- });
36
- }
37
- export const getWorkflowRestBinding = {
29
+ }), getWorkflowRestBinding = {
38
30
  method: "GET",
39
31
  path: "/v1/workflows/:id",
40
32
  pathParamNames: ["id"],
@@ -43,7 +35,5 @@ export const getWorkflowRestBinding = {
43
35
  workflowId: { kind: "path", pathParam: "id" }
44
36
  },
45
37
  extractInput: async (_request, pathParams) => ({ workflowId: pathParams.id ?? "" }),
46
- success: { kind: "json", status: 200 },
47
- shapeSuccess: (output) => shapeGetWorkflowSuccess(output),
48
- shapeFault: shapeRestFault
38
+ success: { kind: "json", status: 200 }
49
39
  };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `weft.alerts.list` operation + REST binding.
3
+ *
4
+ * Reports the alert rules that are currently firing. The response deliberately
5
+ * omits rule actions and webhook destinations: this is an operator diagnostic
6
+ * surface, not a configuration export.
7
+ */
8
+ import { z } from 'zod';
9
+ import type { UnknownRestBinding } from '../rest-bindings.ts';
10
+ declare const listAlertsInput: z.ZodObject<{}, z.core.$strip>;
11
+ declare const activeAlertSchema: z.ZodObject<{
12
+ metric: z.ZodEnum<{
13
+ "workflow.failure_rate": "workflow.failure_rate";
14
+ "activity.p99_duration": "activity.p99_duration";
15
+ "storage.size": "storage.size";
16
+ }>;
17
+ threshold: z.ZodNumber;
18
+ currentValue: z.ZodNumber;
19
+ window: z.ZodNullable<z.ZodString>;
20
+ firedAt: z.ZodNullable<z.ZodNumber>;
21
+ }, z.core.$strip>;
22
+ export type ListAlertsInput = z.infer<typeof listAlertsInput>;
23
+ export type ActiveAlert = z.infer<typeof activeAlertSchema>;
24
+ export type ListAlertsOutput = {
25
+ items: ActiveAlert[];
26
+ };
27
+ export declare const listAlertsOperation: import("../operation-catalog.ts").OperationDefinition<Record<string, never>, ListAlertsOutput, unknown>;
28
+ export declare const listAlertsRestBinding: UnknownRestBinding;
29
+ export {};
@@ -0,0 +1,47 @@
1
+ import { z } from "zod";
2
+ import { ALERT_METRICS } from "../../alerting/types.js";
3
+ import { shapeOperationFaultAsJson } from "../operation-fault.js";
4
+ import { defineOperation } from "../operation-registry.js";
5
+ const alertMetricSchema = z.enum(ALERT_METRICS), listAlertsInput = z.object({}), activeAlertSchema = z.object({
6
+ metric: alertMetricSchema,
7
+ threshold: z.number(),
8
+ currentValue: z.number(),
9
+ window: z.string().nullable(),
10
+ firedAt: z.number().nullable()
11
+ }), listAlertsOutput = z.object({
12
+ items: z.array(activeAlertSchema)
13
+ });
14
+ export const listAlertsOperation = defineOperation({
15
+ name: "weft.alerts.list",
16
+ mcpExposable: !1,
17
+ summary: "List currently firing alerts",
18
+ description: "List the alert rules that are currently firing, including their metric, threshold, current value, configured window, and firing timestamp. Read-only and limited to active in-memory alert state; resolved alerts are not returned.",
19
+ destructive: !1,
20
+ tags: ["Observability"],
21
+ inputSchema: listAlertsInput,
22
+ outputSchema: listAlertsOutput,
23
+ access: { kind: "scoped", scopes: { kind: "anyOf", scopes: ["system:read"] } },
24
+ discoverable: !0,
25
+ transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
26
+ unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
27
+ invoke: async ({ engine }) => {
28
+ return {
29
+ items: engine.getActiveAlerts().map((state) => ({
30
+ metric: state.rule.metric,
31
+ threshold: state.rule.threshold,
32
+ currentValue: state.currentValue,
33
+ window: state.rule.window ?? null,
34
+ firedAt: state.lastFiredAt ?? null
35
+ }))
36
+ };
37
+ }
38
+ }), listAlertsRestBinding = {
39
+ method: "GET",
40
+ path: "/v1/alerts",
41
+ pathParamNames: [],
42
+ operationName: "weft.alerts.list",
43
+ inputSources: {},
44
+ extractInput: async () => ({}),
45
+ success: { kind: "json", status: 200 },
46
+ shapeFault: shapeOperationFaultAsJson
47
+ };
@@ -1,7 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { negotiatedResponse } from "../handler/response-helpers.js";
3
3
  import { defineOperation } from "../operation-registry.js";
4
- import { shapeRestFault } from "./operation-helpers.js";
5
4
  const listCheckpointsInput = z.object({
6
5
  workflowId: z.string().min(1)
7
6
  }), listCheckpointsOutput = z.unknown();
@@ -23,9 +22,6 @@ export const listCheckpointsOperation = defineOperation({
23
22
  function shapeListCheckpointsSuccess(result, request) {
24
23
  return negotiatedResponse(request, result, 200);
25
24
  }
26
- function shapeListCheckpointsFault(fault) {
27
- return shapeRestFault(fault);
28
- }
29
25
  export const listCheckpointsRestBinding = {
30
26
  method: "GET",
31
27
  path: "/v1/workflows/:id/checkpoints",
@@ -38,6 +34,5 @@ export const listCheckpointsRestBinding = {
38
34
  workflowId: pathParams.id ?? ""
39
35
  }),
40
36
  success: { kind: "json", status: 200 },
41
- shapeSuccess: (output, request) => shapeListCheckpointsSuccess(output, request),
42
- shapeFault: shapeListCheckpointsFault
37
+ shapeSuccess: (output, request) => shapeListCheckpointsSuccess(output, request)
43
38
  };
@@ -37,12 +37,6 @@ function extractListReviewsInput(request) {
37
37
  filter.reviewType = reviewType;
38
38
  return filter;
39
39
  }
40
- function shapeListReviewsSuccess(result) {
41
- return new Response(JSON.stringify(result), {
42
- status: 200,
43
- headers: { "Content-Type": "application/json" }
44
- });
45
- }
46
40
  export const listReviewsRestBinding = {
47
41
  method: "GET",
48
42
  path: "/v1/reviews",
@@ -55,6 +49,5 @@ export const listReviewsRestBinding = {
55
49
  },
56
50
  extractInput: async (request) => extractListReviewsInput(request),
57
51
  success: { kind: "json", status: 200 },
58
- shapeSuccess: (output) => shapeListReviewsSuccess(output),
59
52
  shapeFault: shapeOperationFaultAsJson
60
53
  };
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { defineOperation } from "../operation-registry.js";
3
- import { invalidParamsFault, shapeRestFault } from "./operation-helpers.js";
3
+ import { invalidParamsFault } from "./operation-helpers.js";
4
4
  const VALID_SCHEDULE_STATUSES = new Set(["active", "paused", "cancelled"]);
5
5
  function isValidScheduleStatus(value) {
6
6
  return VALID_SCHEDULE_STATUSES.has(value);
@@ -71,11 +71,7 @@ export const listSchedulesOperation = defineOperation({
71
71
  const e = engine, filter = validateListSchedulesQuery(input);
72
72
  return e.listSchedules(filter);
73
73
  }
74
- });
75
- function shapeListSchedulesFault(fault) {
76
- return shapeRestFault(fault);
77
- }
78
- export const listSchedulesRestBinding = {
74
+ }), listSchedulesRestBinding = {
79
75
  method: "GET",
80
76
  path: "/v1/schedules",
81
77
  pathParamNames: [],
@@ -103,6 +99,5 @@ export const listSchedulesRestBinding = {
103
99
  result.offset = offset;
104
100
  return result;
105
101
  },
106
- success: { kind: "json", status: 200 },
107
- shapeFault: shapeListSchedulesFault
102
+ success: { kind: "json", status: 200 }
108
103
  };
@@ -96,10 +96,6 @@ export function createListTaskQueuesRestBinding() {
96
96
  inputSources: {},
97
97
  extractInput: async () => ({}),
98
98
  success: { kind: "json", status: 200 },
99
- shapeSuccess: (output) => new Response(JSON.stringify(output), {
100
- status: 200,
101
- headers: { "Content-Type": "application/json" }
102
- }),
103
99
  shapeFault: shapeOperationFaultAsJson
104
100
  };
105
101
  }
@@ -83,10 +83,6 @@ export function createListWorkersRestBinding() {
83
83
  inputSources: {},
84
84
  extractInput: async () => ({}),
85
85
  success: { kind: "json", status: 200 },
86
- shapeSuccess: (output) => new Response(JSON.stringify(output), {
87
- status: 200,
88
- headers: { "Content-Type": "application/json" }
89
- }),
90
86
  shapeFault: shapeOperationFaultAsJson
91
87
  };
92
88
  }