@lostgradient/weft 0.16.0 → 0.18.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 (119) hide show
  1. package/README.md +1 -1
  2. package/dist/alerting/alert-manager.d.ts +5 -5
  3. package/dist/alerting/alert-manager.js +24 -6
  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/generated/operation-catalog.snapshot.json +73 -0
  8. package/dist/cli/generated/operation-client.generated.d.ts +11 -2
  9. package/dist/cli/generated/operation-client.generated.js +2 -0
  10. package/dist/core/engine/disposal.js +7 -0
  11. package/dist/core/engine/engine-runtime-helpers.d.ts +3 -1
  12. package/dist/core/engine/engine-runtime-helpers.js +2 -2
  13. package/dist/core/engine/errors.d.ts +20 -0
  14. package/dist/core/engine/errors.js +8 -0
  15. package/dist/core/engine/index.d.ts +39 -17
  16. package/dist/core/engine/index.js +81 -9
  17. package/dist/core/engine/inline-launch-queue.d.ts +6 -2
  18. package/dist/core/engine/inline-launch-queue.js +41 -6
  19. package/dist/core/engine/internals.d.ts +2 -0
  20. package/dist/core/engine/lease-manager.d.ts +3 -2
  21. package/dist/core/engine/lease-manager.js +7 -3
  22. package/dist/core/engine/operations-time.js +6 -0
  23. package/dist/core/execution-strategy.d.ts +8 -0
  24. package/dist/core/inline-execution-strategy.d.ts +1 -0
  25. package/dist/core/inline-execution-strategy.js +33 -20
  26. package/dist/core/weft-error.d.ts +1 -1
  27. package/dist/core/weft-error.js +1 -0
  28. package/dist/core/worker-execution-strategy.d.ts +2 -0
  29. package/dist/core/worker-execution-strategy.js +7 -2
  30. package/dist/core/worker-turn-watchdog.d.ts +4 -1
  31. package/dist/core/worker-turn-watchdog.js +9 -4
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +1 -0
  34. package/dist/indexeddb.js +1 -1
  35. package/dist/json-schema.js +1 -1
  36. package/dist/mcp/tools.js +1 -3
  37. package/dist/server/authorization-scope.d.ts +32 -2
  38. package/dist/server/dashboard-assets.d.ts +12 -1
  39. package/dist/server/dashboard-assets.js +145 -31
  40. package/dist/server/index.d.ts +2 -0
  41. package/dist/server/index.js +4 -0
  42. package/dist/server/operations/aggregate-workflows.js +0 -7
  43. package/dist/server/operations/async-activity.js +5 -24
  44. package/dist/server/operations/bulk-cancel-workflows.js +3 -8
  45. package/dist/server/operations/bulk-delete-workflows.js +3 -8
  46. package/dist/server/operations/bulk-mutate-workflow-tags.js +3 -8
  47. package/dist/server/operations/bulk-operation-helpers.d.ts +2 -10
  48. package/dist/server/operations/bulk-operation-helpers.js +0 -6
  49. package/dist/server/operations/bulk-retry-failed-workflows.js +3 -8
  50. package/dist/server/operations/bulk-signal-workflows.js +3 -8
  51. package/dist/server/operations/cancel-schedule.js +1 -3
  52. package/dist/server/operations/cancel-workflow.js +1 -3
  53. package/dist/server/operations/create-schedule.js +2 -3
  54. package/dist/server/operations/fork-workflow.js +2 -3
  55. package/dist/server/operations/get-checkpoint-at.js +1 -6
  56. package/dist/server/operations/get-principal.d.ts +75 -0
  57. package/dist/server/operations/get-principal.js +41 -0
  58. package/dist/server/operations/get-registry.js +1 -7
  59. package/dist/server/operations/get-retention-overview.js +2 -15
  60. package/dist/server/operations/get-review.js +2 -15
  61. package/dist/server/operations/get-schedule.js +2 -8
  62. package/dist/server/operations/get-stream-chunks.js +2 -6
  63. package/dist/server/operations/get-system-lease.js +1 -7
  64. package/dist/server/operations/get-system-metrics.js +0 -4
  65. package/dist/server/operations/get-task-diagnostics.js +2 -13
  66. package/dist/server/operations/get-update-result.js +1 -6
  67. package/dist/server/operations/get-workflow-attributes.js +2 -15
  68. package/dist/server/operations/get-workflow-events.js +2 -15
  69. package/dist/server/operations/get-workflow-observability.js +2 -5
  70. package/dist/server/operations/get-workflow-result.js +0 -7
  71. package/dist/server/operations/get-workflow-timeline.js +1 -6
  72. package/dist/server/operations/get-workflow.d.ts +3 -6
  73. package/dist/server/operations/get-workflow.js +2 -12
  74. package/dist/server/operations/list-alerts.d.ts +5 -2
  75. package/dist/server/operations/list-alerts.js +2 -9
  76. package/dist/server/operations/list-checkpoints.js +1 -6
  77. package/dist/server/operations/list-reviews.js +0 -7
  78. package/dist/server/operations/list-schedules.js +3 -8
  79. package/dist/server/operations/list-task-queues.js +0 -4
  80. package/dist/server/operations/list-workers.js +0 -4
  81. package/dist/server/operations/list-workflows.js +0 -7
  82. package/dist/server/operations/pause-schedule.js +1 -3
  83. package/dist/server/operations/purge-workflows.js +2 -5
  84. package/dist/server/operations/query-workflow.js +4 -15
  85. package/dist/server/operations/replay-workflow.js +2 -6
  86. package/dist/server/operations/resume-schedule.js +1 -3
  87. package/dist/server/operations/resume-workflow.js +1 -3
  88. package/dist/server/operations/set-workflow-attributes.js +3 -15
  89. package/dist/server/operations/signal-workflow.js +3 -12
  90. package/dist/server/operations/single-workflow-tag-mutation.js +0 -7
  91. package/dist/server/operations/start-or-signal-workflow.js +2 -3
  92. package/dist/server/operations/start-workflow.js +2 -3
  93. package/dist/server/operations/static-registrations.d.ts +28 -0
  94. package/dist/server/operations/static-registrations.js +263 -0
  95. package/dist/server/operations/storage-capabilities.js +1 -3
  96. package/dist/server/operations/storage.js +7 -13
  97. package/dist/server/operations/submit-review-decision.js +3 -12
  98. package/dist/server/operations/suspend-workflow.js +1 -3
  99. package/dist/server/operations/timeout-workflow.js +1 -3
  100. package/dist/server/operations/update-schedule.js +1 -3
  101. package/dist/server/operations/update-workflow.js +2 -3
  102. package/dist/server/operations/worker-drain.js +0 -8
  103. package/dist/server/rest-binding.d.ts +3 -2
  104. package/dist/server/rest-bindings.d.ts +5 -0
  105. package/dist/server/rest-bindings.js +4 -312
  106. package/dist/server/route-model.d.ts +2 -0
  107. package/dist/server/route-model.js +1 -1
  108. package/dist/server/runtime/task-reconciliation.d.ts +10 -1
  109. package/dist/server/runtime/task-reconciliation.js +26 -2
  110. package/dist/server/serve-internals.js +12 -6
  111. package/dist/storage/indexeddb.js +28 -48
  112. package/dist/storage/testing.d.ts +6 -3
  113. package/dist/storage/testing.js +1 -1
  114. package/dist/version.d.ts +1 -1
  115. package/dist/version.js +1 -1
  116. package/dist/worker/protocol-schemas.d.ts +2 -2
  117. package/dist/worker/protocol-schemas.js +2 -2
  118. package/dist/worker/protocol.js +1 -1
  119. package/package.json +1 -1
@@ -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
  import { mapScheduleErrorToFault } from "./schedule-faults.js";
5
4
  const cancelScheduleInput = z.object({
6
5
  scheduleId: z.string().min(1)
@@ -38,6 +37,5 @@ export const cancelScheduleOperation = defineOperation({
38
37
  extractInput: async (_request, pathParams) => ({
39
38
  scheduleId: pathParams.id ?? ""
40
39
  }),
41
- success: { kind: "empty", status: 204 },
42
- shapeFault: shapeRestFault
40
+ success: { kind: "empty", status: 204 }
43
41
  };
@@ -1,5 +1,4 @@
1
1
  import { z } from "zod";
2
- import { shapeRestFault } from "./operation-helpers.js";
3
2
  import {
4
3
  createSingleWorkflowControlOperation,
5
4
  extractWorkflowIdFromPath
@@ -29,6 +28,5 @@ export const cancelWorkflowOperation = createSingleWorkflowControlOperation({
29
28
  workflowId: { kind: "path", pathParam: "id" }
30
29
  },
31
30
  extractInput: async (_request, pathParams) => extractWorkflowIdFromPath(pathParams),
32
- success: { kind: "empty", status: 204 },
33
- shapeFault: shapeRestFault
31
+ success: { kind: "empty", status: 204 }
34
32
  };
@@ -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
  import {
5
5
  mapScheduleErrorToFault,
6
6
  validateScheduleInputCadence,
@@ -101,6 +101,5 @@ export const createScheduleOperation = defineOperation({
101
101
  ...extractSharedScheduleRestFields(record)
102
102
  };
103
103
  },
104
- success: { kind: "json", status: 201 },
105
- shapeFault: shapeRestFault
104
+ success: { kind: "json", status: 201 }
106
105
  };
@@ -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
  };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * `weft.system.principal` operation + REST binding.
3
+ *
4
+ * Reports the caller's own resolved principal: the authentication method,
5
+ * the normalized subject, and the granted scope set. Public access by
6
+ * design — introspection has to work for every credential state to be
7
+ * useful (a dashboard probes its principal before it knows anything), and
8
+ * an unauthenticated caller learns only what it already knows: that it is
9
+ * anonymous with no scopes. The response is strictly principal-shaped —
10
+ * nothing about the server's auth configuration (key inventory,
11
+ * `unauthenticatedAccess` posture, JWT issuers) is exposed.
12
+ */
13
+ import { z } from 'zod';
14
+ import type { UnknownRestBinding } from '../rest-bindings.ts';
15
+ declare const getPrincipalInput: z.ZodObject<{}, z.core.$strip>;
16
+ declare const getPrincipalOutput: z.ZodObject<{
17
+ method: z.ZodEnum<{
18
+ jwt: "jwt";
19
+ "api-key": "api-key";
20
+ mtls: "mtls";
21
+ "stdio-local": "stdio-local";
22
+ unauthenticated: "unauthenticated";
23
+ }>;
24
+ subject: z.ZodNullable<z.ZodString>;
25
+ scopes: z.ZodArray<z.ZodEnum<{
26
+ "workflows:read": "workflows:read";
27
+ "workflows:write": "workflows:write";
28
+ "workflows:admin": "workflows:admin";
29
+ "schedules:read": "schedules:read";
30
+ "schedules:write": "schedules:write";
31
+ "signals:write": "signals:write";
32
+ "updates:write": "updates:write";
33
+ "queries:read": "queries:read";
34
+ "reviews:read": "reviews:read";
35
+ "reviews:write": "reviews:write";
36
+ "attributes:read": "attributes:read";
37
+ "attributes:write": "attributes:write";
38
+ "tags:write": "tags:write";
39
+ "streams:read": "streams:read";
40
+ "events:read": "events:read";
41
+ "storage:read": "storage:read";
42
+ "storage:write": "storage:write";
43
+ "storage:admin": "storage:admin";
44
+ "workers:write": "workers:write";
45
+ "system:read": "system:read";
46
+ "system:admin": "system:admin";
47
+ }>>;
48
+ }, z.core.$strip>;
49
+ export type GetPrincipalInput = z.infer<typeof getPrincipalInput>;
50
+ /**
51
+ * Output of `weft.system.principal`: the caller's authentication method,
52
+ * normalized subject (`null` when the credential carries none), and granted
53
+ * scopes, sorted. Anonymous callers receive `method: 'unauthenticated'`
54
+ * with an empty scope list.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { type GetPrincipalOutput } from '@lostgradient/weft/server';
59
+ *
60
+ * const anonymous: GetPrincipalOutput = {
61
+ * method: 'unauthenticated',
62
+ * subject: null,
63
+ * scopes: [],
64
+ * };
65
+ * console.log(anonymous.method);
66
+ * ```
67
+ */
68
+ export type GetPrincipalOutput = z.infer<typeof getPrincipalOutput>;
69
+ export declare const getPrincipalOperation: import("../operation-catalog.ts").OperationDefinition<Record<string, never>, {
70
+ method: "jwt" | "api-key" | "mtls" | "stdio-local" | "unauthenticated";
71
+ subject: string | null;
72
+ scopes: ("workflows:read" | "workflows:write" | "workflows:admin" | "schedules:read" | "schedules:write" | "signals:write" | "updates:write" | "queries:read" | "reviews:read" | "reviews:write" | "attributes:read" | "attributes:write" | "tags:write" | "streams:read" | "events:read" | "storage:read" | "storage:write" | "storage:admin" | "workers:write" | "system:read" | "system:admin")[];
73
+ }, unknown>;
74
+ export declare const getPrincipalRestBinding: UnknownRestBinding;
75
+ export {};
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ import { AUTHORIZATION_SCOPES } from "../authorization-scope.js";
3
+ import { shapeOperationFaultAsJson } from "../operation-fault.js";
4
+ import { defineOperation } from "../operation-registry.js";
5
+ const principalMethodSchema = z.enum(["jwt", "api-key", "mtls", "stdio-local", "unauthenticated"]), getPrincipalInput = z.object({}), getPrincipalOutput = z.object({
6
+ method: principalMethodSchema,
7
+ subject: z.string().nullable(),
8
+ scopes: z.array(z.enum(AUTHORIZATION_SCOPES))
9
+ });
10
+ export const getPrincipalOperation = defineOperation({
11
+ name: "weft.system.principal",
12
+ mcpExposable: !1,
13
+ summary: "Report the caller's resolved principal and granted scopes",
14
+ description: `Report the caller's own resolved principal: the authentication method ('jwt', 'api-key', 'mtls', 'stdio-local', or 'unauthenticated'), the normalized subject when one exists, and the granted authorization scopes, sorted. Public access: an unauthenticated caller receives method 'unauthenticated' with an empty scope list rather than an error, so clients can distinguish "no credential" from "credential with few scopes" without probing ` + "other operations. Reflects only the request credential \u2014 never server auth configuration.",
15
+ destructive: !1,
16
+ tags: ["System"],
17
+ inputSchema: getPrincipalInput,
18
+ outputSchema: getPrincipalOutput,
19
+ access: { kind: "public" },
20
+ discoverable: !0,
21
+ transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
22
+ unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
23
+ invoke: async ({ principal }) => {
24
+ if (principal.method === "unauthenticated")
25
+ return { method: "unauthenticated", subject: null, scopes: [] };
26
+ return {
27
+ method: principal.method,
28
+ subject: principal.subject ?? null,
29
+ scopes: [...principal.scopes].toSorted()
30
+ };
31
+ }
32
+ }), getPrincipalRestBinding = {
33
+ method: "GET",
34
+ path: "/v1/principal",
35
+ pathParamNames: [],
36
+ operationName: "weft.system.principal",
37
+ inputSources: {},
38
+ extractInput: async () => ({}),
39
+ success: { kind: "json", status: 200 },
40
+ shapeFault: shapeOperationFaultAsJson
41
+ };
@@ -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
  };