@cleocode/lafs 2026.4.0 → 2026.4.4

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 (131) hide show
  1. package/README.md +97 -68
  2. package/dist/src/a2a/bindings/grpc.d.ts +117 -11
  3. package/dist/src/a2a/bindings/grpc.d.ts.map +1 -1
  4. package/dist/src/a2a/bindings/grpc.js +79 -8
  5. package/dist/src/a2a/bindings/grpc.js.map +1 -1
  6. package/dist/src/a2a/bindings/http.d.ts +129 -14
  7. package/dist/src/a2a/bindings/http.d.ts.map +1 -1
  8. package/dist/src/a2a/bindings/http.js +93 -12
  9. package/dist/src/a2a/bindings/http.js.map +1 -1
  10. package/dist/src/a2a/bindings/index.d.ts +80 -7
  11. package/dist/src/a2a/bindings/index.d.ts.map +1 -1
  12. package/dist/src/a2a/bindings/index.js +69 -2
  13. package/dist/src/a2a/bindings/index.js.map +1 -1
  14. package/dist/src/a2a/bindings/jsonrpc.d.ts +193 -9
  15. package/dist/src/a2a/bindings/jsonrpc.d.ts.map +1 -1
  16. package/dist/src/a2a/bindings/jsonrpc.js +152 -9
  17. package/dist/src/a2a/bindings/jsonrpc.js.map +1 -1
  18. package/dist/src/a2a/bridge.d.ts +232 -37
  19. package/dist/src/a2a/bridge.d.ts.map +1 -1
  20. package/dist/src/a2a/bridge.js +172 -24
  21. package/dist/src/a2a/bridge.js.map +1 -1
  22. package/dist/src/a2a/extensions.d.ts +221 -12
  23. package/dist/src/a2a/extensions.d.ts.map +1 -1
  24. package/dist/src/a2a/extensions.js +175 -11
  25. package/dist/src/a2a/extensions.js.map +1 -1
  26. package/dist/src/a2a/index.d.ts +2 -0
  27. package/dist/src/a2a/index.d.ts.map +1 -1
  28. package/dist/src/a2a/index.js +2 -0
  29. package/dist/src/a2a/index.js.map +1 -1
  30. package/dist/src/a2a/streaming.d.ts +274 -2
  31. package/dist/src/a2a/streaming.d.ts.map +1 -1
  32. package/dist/src/a2a/streaming.js +245 -2
  33. package/dist/src/a2a/streaming.js.map +1 -1
  34. package/dist/src/a2a/task-lifecycle.d.ts +339 -19
  35. package/dist/src/a2a/task-lifecycle.d.ts.map +1 -1
  36. package/dist/src/a2a/task-lifecycle.js +302 -19
  37. package/dist/src/a2a/task-lifecycle.js.map +1 -1
  38. package/dist/src/budgetEnforcement.d.ts +88 -14
  39. package/dist/src/budgetEnforcement.d.ts.map +1 -1
  40. package/dist/src/budgetEnforcement.js +132 -19
  41. package/dist/src/budgetEnforcement.js.map +1 -1
  42. package/dist/src/circuit-breaker/index.d.ts +254 -9
  43. package/dist/src/circuit-breaker/index.d.ts.map +1 -1
  44. package/dist/src/circuit-breaker/index.js +218 -9
  45. package/dist/src/circuit-breaker/index.js.map +1 -1
  46. package/dist/src/compliance.d.ts +176 -0
  47. package/dist/src/compliance.d.ts.map +1 -1
  48. package/dist/src/compliance.js +100 -0
  49. package/dist/src/compliance.js.map +1 -1
  50. package/dist/src/conformance.d.ts +52 -0
  51. package/dist/src/conformance.d.ts.map +1 -1
  52. package/dist/src/conformance.js +41 -0
  53. package/dist/src/conformance.js.map +1 -1
  54. package/dist/src/conformanceProfiles.d.ts +66 -0
  55. package/dist/src/conformanceProfiles.d.ts.map +1 -1
  56. package/dist/src/conformanceProfiles.js +51 -0
  57. package/dist/src/conformanceProfiles.js.map +1 -1
  58. package/dist/src/deprecationRegistry.d.ts +80 -0
  59. package/dist/src/deprecationRegistry.d.ts.map +1 -1
  60. package/dist/src/deprecationRegistry.js +50 -0
  61. package/dist/src/deprecationRegistry.js.map +1 -1
  62. package/dist/src/discovery.d.ts +344 -63
  63. package/dist/src/discovery.d.ts.map +1 -1
  64. package/dist/src/discovery.js +67 -13
  65. package/dist/src/discovery.js.map +1 -1
  66. package/dist/src/envelope.d.ts +252 -0
  67. package/dist/src/envelope.d.ts.map +1 -1
  68. package/dist/src/envelope.js +165 -0
  69. package/dist/src/envelope.js.map +1 -1
  70. package/dist/src/errorRegistry.d.ts +159 -0
  71. package/dist/src/errorRegistry.d.ts.map +1 -1
  72. package/dist/src/errorRegistry.js +115 -0
  73. package/dist/src/errorRegistry.js.map +1 -1
  74. package/dist/src/fieldExtraction.d.ts +125 -25
  75. package/dist/src/fieldExtraction.d.ts.map +1 -1
  76. package/dist/src/fieldExtraction.js +85 -16
  77. package/dist/src/fieldExtraction.js.map +1 -1
  78. package/dist/src/flagResolver.d.ts +75 -9
  79. package/dist/src/flagResolver.d.ts.map +1 -1
  80. package/dist/src/flagResolver.js +20 -4
  81. package/dist/src/flagResolver.js.map +1 -1
  82. package/dist/src/flagSemantics.d.ts +76 -1
  83. package/dist/src/flagSemantics.d.ts.map +1 -1
  84. package/dist/src/flagSemantics.js +66 -0
  85. package/dist/src/flagSemantics.js.map +1 -1
  86. package/dist/src/health/index.d.ts +87 -6
  87. package/dist/src/health/index.d.ts.map +1 -1
  88. package/dist/src/health/index.js +54 -6
  89. package/dist/src/health/index.js.map +1 -1
  90. package/dist/src/index.d.ts +12 -1
  91. package/dist/src/index.d.ts.map +1 -1
  92. package/dist/src/index.js +12 -1
  93. package/dist/src/index.js.map +1 -1
  94. package/dist/src/mviProjection.d.ts +42 -6
  95. package/dist/src/mviProjection.d.ts.map +1 -1
  96. package/dist/src/mviProjection.js +31 -5
  97. package/dist/src/mviProjection.js.map +1 -1
  98. package/dist/src/native-loader.d.ts +49 -0
  99. package/dist/src/native-loader.d.ts.map +1 -0
  100. package/dist/src/native-loader.js +56 -0
  101. package/dist/src/native-loader.js.map +1 -0
  102. package/dist/src/problemDetails.d.ts +70 -4
  103. package/dist/src/problemDetails.d.ts.map +1 -1
  104. package/dist/src/problemDetails.js +21 -3
  105. package/dist/src/problemDetails.js.map +1 -1
  106. package/dist/src/shutdown/index.d.ts +96 -7
  107. package/dist/src/shutdown/index.d.ts.map +1 -1
  108. package/dist/src/shutdown/index.js +72 -7
  109. package/dist/src/shutdown/index.js.map +1 -1
  110. package/dist/src/tokenEstimator.d.ts +97 -11
  111. package/dist/src/tokenEstimator.d.ts.map +1 -1
  112. package/dist/src/tokenEstimator.js +90 -11
  113. package/dist/src/tokenEstimator.js.map +1 -1
  114. package/dist/src/types.d.ts +467 -2
  115. package/dist/src/types.d.ts.map +1 -1
  116. package/dist/src/types.js +64 -0
  117. package/dist/src/types.js.map +1 -1
  118. package/dist/src/validateEnvelope.d.ts +59 -1
  119. package/dist/src/validateEnvelope.d.ts.map +1 -1
  120. package/dist/src/validateEnvelope.js +75 -9
  121. package/dist/src/validateEnvelope.js.map +1 -1
  122. package/dist/tsconfig.build.tsbuildinfo +1 -1
  123. package/lafs.md +3 -4
  124. package/package.json +6 -3
  125. package/dist/src/mcpAdapter.d.ts +0 -29
  126. package/dist/src/mcpAdapter.d.ts.map +0 -1
  127. package/dist/src/mcpAdapter.js +0 -286
  128. package/dist/src/mcpAdapter.js.map +0 -1
  129. package/schemas/v1/conformance-profiles.d.ts +0 -15
  130. package/schemas/v1/envelope.schema.d.ts +0 -14
  131. package/schemas/v1/error-registry.d.ts +0 -24
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Native addon loader for lafs-core schema validation via napi-rs.
3
+ *
4
+ * @remarks
5
+ * Loads the napi-rs native addon synchronously on first use. Falls back
6
+ * gracefully if the native addon is not available (e.g., unsupported platform,
7
+ * Rust toolchain not installed). When unavailable, the AJV-based validator
8
+ * in `validateEnvelope.ts` is used instead.
9
+ *
10
+ * Follows the same pattern as `packages/cant/src/native-loader.ts`.
11
+ */
12
+ import { createRequire } from 'node:module';
13
+ let nativeModule = null;
14
+ let loadAttempted = false;
15
+ /**
16
+ * Attempt to load the native addon. Called lazily on first use.
17
+ * Native addons load synchronously via require() — no async init needed.
18
+ */
19
+ function ensureLoaded() {
20
+ if (loadAttempted)
21
+ return;
22
+ loadAttempted = true;
23
+ const req = createRequire(import.meta.url);
24
+ try {
25
+ nativeModule = req('@cleocode/lafs-native');
26
+ }
27
+ catch {
28
+ try {
29
+ // Development fallback: try loading from the crate build output
30
+ nativeModule = req('../../crates/lafs-napi/index.cjs');
31
+ }
32
+ catch {
33
+ // Native addon not available — AJV fallback will be used
34
+ nativeModule = null;
35
+ }
36
+ }
37
+ }
38
+ /**
39
+ * Check if the native addon is available.
40
+ *
41
+ * @returns `true` if the native Rust binding was loaded successfully.
42
+ */
43
+ export function isNativeAvailable() {
44
+ ensureLoaded();
45
+ return nativeModule !== null;
46
+ }
47
+ /**
48
+ * Get the native module, or `null` if unavailable.
49
+ *
50
+ * @returns The loaded native module, or `null` for AJV fallback.
51
+ */
52
+ export function getNativeModule() {
53
+ ensureLoaded();
54
+ return nativeModule;
55
+ }
56
+ //# sourceMappingURL=native-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-loader.js","sourceRoot":"","sources":["../../src/native-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA6B5C,IAAI,YAAY,GAA4B,IAAI,CAAC;AACjD,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B;;;GAGG;AACH,SAAS,YAAY;IACnB,IAAI,aAAa;QAAE,OAAO;IAC1B,aAAa,GAAG,IAAI,CAAC;IAErB,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC;QACH,YAAY,GAAG,GAAG,CAAC,uBAAuB,CAAqB,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,CAAC;YACH,gEAAgE;YAChE,YAAY,GAAG,GAAG,CAAC,kCAAkC,CAAqB,CAAC;QAC7E,CAAC;QAAC,MAAM,CAAC;YACP,yDAAyD;YACzD,YAAY,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,YAAY,EAAE,CAAC;IACf,OAAO,YAAY,KAAK,IAAI,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,YAAY,EAAE,CAAC;IACf,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -4,32 +4,98 @@
4
4
  * Available for any transport, not just HTTP.
5
5
  */
6
6
  import type { LAFSError } from './types.js';
7
- /** RFC 9457 Problem Details with LAFS extensions */
7
+ /**
8
+ * RFC 9457 Problem Details with LAFS extensions.
9
+ *
10
+ * @remarks
11
+ * Extends the standard RFC 9457 Problem Details object with LAFS-specific
12
+ * agent-actionable fields. The index signature allows pass-through of
13
+ * additional error details from {@link LAFSError.details}.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const pd: LafsProblemDetails = {
18
+ * type: "https://lafs.dev/errors/v1/E_VALIDATION",
19
+ * title: "E_VALIDATION",
20
+ * status: 400,
21
+ * detail: "Invalid input",
22
+ * retryable: false,
23
+ * };
24
+ * ```
25
+ */
8
26
  export interface LafsProblemDetails {
27
+ /** URI reference identifying the problem type */
9
28
  type: string;
29
+ /** Short human-readable summary (typically the error code) */
10
30
  title: string;
31
+ /** HTTP status code for this error */
11
32
  status: number;
33
+ /** Human-readable explanation of the specific occurrence */
12
34
  detail: string;
35
+ /**
36
+ * URI reference identifying the specific occurrence (typically the request ID).
37
+ * @defaultValue `undefined`
38
+ */
13
39
  instance?: string;
40
+ /** Whether the operation that caused this error can be retried */
14
41
  retryable: boolean;
42
+ /**
43
+ * Recommended agent action (e.g., `"retry"`, `"escalate"`).
44
+ * @defaultValue `undefined`
45
+ */
15
46
  agentAction?: string;
47
+ /**
48
+ * Suggested delay in milliseconds before retrying.
49
+ * @defaultValue `undefined`
50
+ */
16
51
  retryAfterMs?: number;
52
+ /**
53
+ * Whether the error requires human escalation.
54
+ * @defaultValue `undefined`
55
+ */
17
56
  escalationRequired?: boolean;
57
+ /**
58
+ * Human-readable suggestion for resolving the error.
59
+ * @defaultValue `undefined`
60
+ */
18
61
  suggestedAction?: string;
62
+ /**
63
+ * Documentation URL for more information.
64
+ * @defaultValue `undefined`
65
+ */
19
66
  docUrl?: string;
67
+ /** Pass-through extension members from error details */
20
68
  [key: string]: unknown;
21
69
  }
22
70
  /**
23
71
  * Convert a LAFSError to an RFC 9457 Problem Details object.
72
+ *
73
+ * @param error - The LAFS error to convert
74
+ * @param requestId - Optional request ID to set as the `instance` field
75
+ * @returns An RFC 9457-compliant {@link LafsProblemDetails} object
76
+ *
77
+ * @remarks
24
78
  * Uses the error registry for HTTP status and type URI resolution.
79
+ * Agent-actionable fields (`agentAction`, `escalationRequired`, `suggestedAction`,
80
+ * `docUrl`) are mapped from the error when present. Non-empty `error.details`
81
+ * entries are spread as extension members, skipping keys that already exist
82
+ * in the Problem Details object.
25
83
  *
26
- * Agent-actionable fields (agentAction, escalationRequired, suggestedAction, docUrl)
27
- * are extracted from error.details if present, enabling forward-compatible extension
28
- * without requiring LAFSError type changes.
84
+ * @example
85
+ * ```typescript
86
+ * import { lafsErrorToProblemDetails } from "@cleocode/lafs";
87
+ *
88
+ * const pd = lafsErrorToProblemDetails(envelope.error!, envelope._meta.requestId);
89
+ * // pd.status === 400, pd.type === "https://lafs.dev/errors/v1/E_VALIDATION"
90
+ * ```
29
91
  */
30
92
  export declare function lafsErrorToProblemDetails(error: LAFSError, requestId?: string): LafsProblemDetails;
31
93
  /**
32
94
  * Content-Type for RFC 9457 Problem Details responses.
95
+ *
96
+ * @remarks
97
+ * Per RFC 9457, Problem Details responses MUST be served with this media type
98
+ * to distinguish them from regular JSON responses.
33
99
  */
34
100
  export declare const PROBLEM_DETAILS_CONTENT_TYPE: "application/problem+json";
35
101
  //# sourceMappingURL=problemDetails.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"problemDetails.d.ts","sourceRoot":"","sources":["../../src/problemDetails.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAA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;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,kBAAkB,CA8BpB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,EAAG,0BAAmC,CAAC"}
@@ -6,11 +6,25 @@
6
6
  import { getRegistryCode } from './errorRegistry.js';
7
7
  /**
8
8
  * Convert a LAFSError to an RFC 9457 Problem Details object.
9
+ *
10
+ * @param error - The LAFS error to convert
11
+ * @param requestId - Optional request ID to set as the `instance` field
12
+ * @returns An RFC 9457-compliant {@link LafsProblemDetails} object
13
+ *
14
+ * @remarks
9
15
  * Uses the error registry for HTTP status and type URI resolution.
16
+ * Agent-actionable fields (`agentAction`, `escalationRequired`, `suggestedAction`,
17
+ * `docUrl`) are mapped from the error when present. Non-empty `error.details`
18
+ * entries are spread as extension members, skipping keys that already exist
19
+ * in the Problem Details object.
10
20
  *
11
- * Agent-actionable fields (agentAction, escalationRequired, suggestedAction, docUrl)
12
- * are extracted from error.details if present, enabling forward-compatible extension
13
- * without requiring LAFSError type changes.
21
+ * @example
22
+ * ```typescript
23
+ * import { lafsErrorToProblemDetails } from "@cleocode/lafs";
24
+ *
25
+ * const pd = lafsErrorToProblemDetails(envelope.error!, envelope._meta.requestId);
26
+ * // pd.status === 400, pd.type === "https://lafs.dev/errors/v1/E_VALIDATION"
27
+ * ```
14
28
  */
15
29
  export function lafsErrorToProblemDetails(error, requestId) {
16
30
  const registry = getRegistryCode(error.code);
@@ -46,6 +60,10 @@ export function lafsErrorToProblemDetails(error, requestId) {
46
60
  }
47
61
  /**
48
62
  * Content-Type for RFC 9457 Problem Details responses.
63
+ *
64
+ * @remarks
65
+ * Per RFC 9457, Problem Details responses MUST be served with this media type
66
+ * to distinguish them from regular JSON responses.
49
67
  */
50
68
  export const PROBLEM_DETAILS_CONTENT_TYPE = 'application/problem+json';
51
69
  //# sourceMappingURL=problemDetails.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"problemDetails.js","sourceRoot":"","sources":["../../src/problemDetails.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqBrD;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAgB,EAChB,SAAkB;IAElB,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE7C,MAAM,EAAE,GAAuB;QAC7B,IAAI,EAAE,8BAA8B,KAAK,CAAC,IAAI,EAAE;QAChD,KAAK,EAAE,KAAK,CAAC,IAAI;QACjB,MAAM,EAAE,QAAQ,EAAE,UAAU,IAAI,GAAG;QACnC,MAAM,EAAE,KAAK,CAAC,OAAO;QACrB,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC;IAEF,IAAI,SAAS;QAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IACvC,IAAI,KAAK,CAAC,YAAY,IAAI,IAAI;QAAE,EAAE,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;IAErE,wCAAwC;IACxC,IAAI,KAAK,CAAC,WAAW,IAAI,IAAI;QAAE,EAAE,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IAClE,IAAI,KAAK,CAAC,kBAAkB,IAAI,IAAI;QAAE,EAAE,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC;IACvF,IAAI,KAAK,CAAC,eAAe,IAAI,IAAI;QAAE,EAAE,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;IAC9E,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI;QAAE,EAAE,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAEnD,gDAAgD;I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IAAI;QAAE,EAAE,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IAClE,IAAI,KAAK,CAAC,kBAAkB,IAAI,IAAI;QAAE,EAAE,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC;IACvF,IAAI,KAAK,CAAC,eAAe,IAAI,IAAI;QAAE,EAAE,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;IAC9E,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI;QAAE,EAAE,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAEnD,gDAAgD;IAChD,IAAI,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YACzD,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC;gBACjB,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAAmC,CAAC"}
@@ -1,22 +1,58 @@
1
1
  /**
2
2
  * LAFS Graceful Shutdown Module
3
3
  *
4
- * Handles graceful shutdown of LAFS servers
4
+ * Handles graceful shutdown of LAFS servers.
5
+ *
6
+ * @packageDocumentation
5
7
  */
6
8
  import type { Server } from 'http';
9
+ /** Configuration for the {@link gracefulShutdown} handler. */
7
10
  export interface GracefulShutdownConfig {
11
+ /**
12
+ * Maximum time in milliseconds to wait for in-flight requests before forcing exit.
13
+ * @defaultValue 30000
14
+ */
8
15
  timeout?: number;
16
+ /**
17
+ * POSIX signals that trigger a graceful shutdown.
18
+ * @defaultValue ['SIGTERM', 'SIGINT']
19
+ */
9
20
  signals?: NodeJS.Signals[];
21
+ /**
22
+ * Callback invoked at the start of shutdown, before the server stops accepting connections.
23
+ * @defaultValue undefined
24
+ */
10
25
  onShutdown?: () => Promise<void> | void;
26
+ /**
27
+ * Callback invoked after all connections have closed (or the timeout elapsed).
28
+ * @defaultValue undefined
29
+ */
11
30
  onClose?: () => Promise<void> | void;
12
31
  }
32
+ /** Snapshot of the current shutdown state. */
13
33
  export interface ShutdownState {
34
+ /** Whether a shutdown sequence is currently in progress. */
14
35
  isShuttingDown: boolean;
36
+ /** Number of TCP connections still open. */
15
37
  activeConnections: number;
38
+ /**
39
+ * Timestamp when the shutdown sequence began.
40
+ * @defaultValue undefined
41
+ */
16
42
  shutdownStartTime?: Date;
17
43
  }
18
44
  /**
19
- * Enable graceful shutdown for an HTTP server
45
+ * Enable graceful shutdown for an HTTP server.
46
+ *
47
+ * @remarks
48
+ * Registers listeners for the configured signals (and uncaught errors) that
49
+ * trigger an orderly shutdown sequence: invoke the `onShutdown` callback,
50
+ * stop accepting new connections, drain existing connections up to the
51
+ * timeout, invoke the `onClose` callback, and exit the process. New
52
+ * connections received after shutdown starts are immediately destroyed.
53
+ *
54
+ * @param server - The Node.js HTTP server to manage
55
+ * @param config - Optional shutdown configuration
20
56
  *
21
57
  * @example
22
58
  * ```typescript
@@ -38,19 +74,65 @@ export interface ShutdownState {
38
74
  */
39
75
  export declare function gracefulShutdown(server: Server, config?: GracefulShutdownConfig): void;
40
76
  /**
41
- * Check if server is shutting down
77
+ * Check whether a shutdown sequence is currently in progress.
78
+ *
79
+ * @remarks
80
+ * Returns `true` once a shutdown signal has been received and the shutdown
81
+ * handler has started executing. Useful for guards that need to short-circuit
82
+ * work when the process is going down.
83
+ *
84
+ * @returns `true` if the server is shutting down, `false` otherwise
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * if (isShuttingDown()) {
89
+ * return; // skip expensive work
90
+ * }
91
+ * ```
42
92
  */
43
93
  export declare function isShuttingDown(): boolean;
44
94
  /**
45
- * Get shutdown state
95
+ * Get a snapshot of the current shutdown state.
96
+ *
97
+ * @remarks
98
+ * Returns a shallow copy of the internal {@link ShutdownState}, including
99
+ * whether shutdown is in progress, the active connection count, and the
100
+ * shutdown start time (if applicable).
101
+ *
102
+ * @returns A copy of the current {@link ShutdownState}
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const state = getShutdownState();
107
+ * console.log(`Connections: ${state.activeConnections}`);
108
+ * ```
46
109
  */
47
110
  export declare function getShutdownState(): ShutdownState;
48
111
  /**
49
- * Force immediate shutdown (emergency use only)
112
+ * Terminate the process immediately without waiting for connections to drain.
113
+ *
114
+ * @remarks
115
+ * Calls `process.exit()` with the given exit code. Intended only for
116
+ * emergency situations where a graceful shutdown has stalled or a fatal
117
+ * condition prevents orderly teardown.
118
+ *
119
+ * @param exitCode - Process exit code
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * forceShutdown(1);
124
+ * ```
50
125
  */
51
126
  export declare function forceShutdown(exitCode?: number): void;
52
127
  /**
53
- * Middleware to reject requests during shutdown
128
+ * Express middleware that rejects requests with 503 while the server is shutting down.
129
+ *
130
+ * @remarks
131
+ * Should be mounted early in the middleware stack so that new requests are
132
+ * immediately rejected once shutdown begins, preventing work from starting
133
+ * that cannot complete before the process exits.
134
+ *
135
+ * @returns An Express-compatible middleware function
54
136
  *
55
137
  * @example
56
138
  * ```typescript
@@ -63,7 +145,14 @@ export declare function shutdownMiddleware(): (_req: unknown, res: {
63
145
  };
64
146
  }, next: () => void) => void;
65
147
  /**
66
- * Wait for shutdown to complete
148
+ * Wait until a shutdown sequence begins.
149
+ *
150
+ * @remarks
151
+ * Polls the internal shutdown state every 100ms and resolves once
152
+ * `isShuttingDown` becomes `true`. Useful for test harnesses or background
153
+ * workers that need to block until the process is going down.
154
+ *
155
+ * @returns A promise that resolves when shutdown has started
67
156
  *
68
157
  * @example
69
158
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shutdown/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,IAAI,CAAC;CAC1B;AAOD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,sBAA2B,GAAG,IAAI,CAoC1F;AAgED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,GAAE,MAAU,GAAG,IAAI,CAGxD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,KAE9B,MAAM,OAAO,EACb,KAAK;IAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,CAAA;CAAE,EACpE,MAAM,MAAM,IAAI,UAWnB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAIrD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shutdown/index.ts"],"names":[],"mappings":"AAAA;;;;;;GA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B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAIrD"}
@@ -1,14 +1,26 @@
1
1
  /**
2
2
  * LAFS Graceful Shutdown Module
3
3
  *
4
- * Handles graceful shutdown of LAFS servers
4
+ * Handles graceful shutdown of LAFS servers.
5
+ *
6
+ * @packageDocumentation
5
7
  */
6
8
  const state = {
7
9
  isShuttingDown: false,
8
10
  activeConnections: 0,
9
11
  };
10
12
  /**
11
- * Enable graceful shutdown for an HTTP server
13
+ * Enable graceful shutdown for an HTTP server.
14
+ *
15
+ * @remarks
16
+ * Registers listeners for the configured signals (and uncaught errors) that
17
+ * trigger an orderly shutdown sequence: invoke the `onShutdown` callback,
18
+ * stop accepting new connections, drain existing connections up to the
19
+ * timeout, invoke the `onClose` callback, and exit the process. New
20
+ * connections received after shutdown starts are immediately destroyed.
21
+ *
22
+ * @param server - The Node.js HTTP server to manage
23
+ * @param config - Optional shutdown configuration
12
24
  *
13
25
  * @example
14
26
  * ```typescript
@@ -107,26 +119,72 @@ function sleep(ms) {
107
119
  return new Promise((resolve) => setTimeout(resolve, ms));
108
120
  }
109
121
  /**
110
- * Check if server is shutting down
122
+ * Check whether a shutdown sequence is currently in progress.
123
+ *
124
+ * @remarks
125
+ * Returns `true` once a shutdown signal has been received and the shutdown
126
+ * handler has started executing. Useful for guards that need to short-circuit
127
+ * work when the process is going down.
128
+ *
129
+ * @returns `true` if the server is shutting down, `false` otherwise
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * if (isShuttingDown()) {
134
+ * return; // skip expensive work
135
+ * }
136
+ * ```
111
137
  */
112
138
  export function isShuttingDown() {
113
139
  return state.isShuttingDown;
114
140
  }
115
141
  /**
116
- * Get shutdown state
142
+ * Get a snapshot of the current shutdown state.
143
+ *
144
+ * @remarks
145
+ * Returns a shallow copy of the internal {@link ShutdownState}, including
146
+ * whether shutdown is in progress, the active connection count, and the
147
+ * shutdown start time (if applicable).
148
+ *
149
+ * @returns A copy of the current {@link ShutdownState}
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const state = getShutdownState();
154
+ * console.log(`Connections: ${state.activeConnections}`);
155
+ * ```
117
156
  */
118
157
  export function getShutdownState() {
119
158
  return { ...state };
120
159
  }
121
160
  /**
122
- * Force immediate shutdown (emergency use only)
161
+ * Terminate the process immediately without waiting for connections to drain.
162
+ *
163
+ * @remarks
164
+ * Calls `process.exit()` with the given exit code. Intended only for
165
+ * emergency situations where a graceful shutdown has stalled or a fatal
166
+ * condition prevents orderly teardown.
167
+ *
168
+ * @param exitCode - Process exit code
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * forceShutdown(1);
173
+ * ```
123
174
  */
124
175
  export function forceShutdown(exitCode = 1) {
125
176
  console.log('Force shutting down...');
126
177
  process.exit(exitCode);
127
178
  }
128
179
  /**
129
- * Middleware to reject requests during shutdown
180
+ * Express middleware that rejects requests with 503 while the server is shutting down.
181
+ *
182
+ * @remarks
183
+ * Should be mounted early in the middleware stack so that new requests are
184
+ * immediately rejected once shutdown begins, preventing work from starting
185
+ * that cannot complete before the process exits.
186
+ *
187
+ * @returns An Express-compatible middleware function
130
188
  *
131
189
  * @example
132
190
  * ```typescript
@@ -146,7 +204,14 @@ export function shutdownMiddleware() {
146
204
  };
147
205
  }
148
206
  /**
149
- * Wait for shutdown to complete
207
+ * Wait until a shutdown sequence begins.
208
+ *
209
+ * @remarks
210
+ * Polls the internal shutdown state every 100ms and resolves once
211
+ * `isShuttingDown` becomes `true`. Useful for test harnesses or background
212
+ * workers that need to block until the process is going down.
213
+ *
214
+ * @returns A promise that resolves when shutdown has started
150
215
  *
151
216
  * @example
152
217
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shutdown/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,MAAM,KAAK,GAAkB;IAC3B,cAAc,EAAE,KAAK;IACrB,iBAAiB,EAAE,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoB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