@cleocode/lafs 2026.3.74 → 2026.4.3

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 (143) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +97 -68
  3. package/dist/schemas/v1/agent-card.schema.json +230 -0
  4. package/dist/schemas/v1/conformance-profiles.json +0 -0
  5. package/dist/schemas/v1/context-ledger.schema.json +70 -0
  6. package/dist/schemas/v1/discovery.schema.json +132 -0
  7. package/dist/schemas/v1/envelope.schema.json +0 -0
  8. package/dist/schemas/v1/error-registry.json +0 -0
  9. package/dist/src/a2a/bindings/grpc.d.ts +118 -11
  10. package/dist/src/a2a/bindings/grpc.d.ts.map +1 -0
  11. package/dist/src/a2a/bindings/grpc.js +80 -8
  12. package/dist/src/a2a/bindings/grpc.js.map +1 -0
  13. package/dist/src/a2a/bindings/http.d.ts +131 -15
  14. package/dist/src/a2a/bindings/http.d.ts.map +1 -0
  15. package/dist/src/a2a/bindings/http.js +101 -14
  16. package/dist/src/a2a/bindings/http.js.map +1 -0
  17. package/dist/src/a2a/bindings/index.d.ts +83 -9
  18. package/dist/src/a2a/bindings/index.d.ts.map +1 -0
  19. package/dist/src/a2a/bindings/index.js +74 -6
  20. package/dist/src/a2a/bindings/index.js.map +1 -0
  21. package/dist/src/a2a/bindings/jsonrpc.d.ts +194 -9
  22. package/dist/src/a2a/bindings/jsonrpc.d.ts.map +1 -0
  23. package/dist/src/a2a/bindings/jsonrpc.js +155 -10
  24. package/dist/src/a2a/bindings/jsonrpc.js.map +1 -0
  25. package/dist/src/a2a/bridge.d.ts +237 -44
  26. package/dist/src/a2a/bridge.d.ts.map +1 -0
  27. package/dist/src/a2a/bridge.js +187 -48
  28. package/dist/src/a2a/bridge.js.map +1 -0
  29. package/dist/src/a2a/extensions.d.ts +222 -12
  30. package/dist/src/a2a/extensions.d.ts.map +1 -0
  31. package/dist/src/a2a/extensions.js +178 -13
  32. package/dist/src/a2a/extensions.js.map +1 -0
  33. package/dist/src/a2a/index.d.ts +10 -7
  34. package/dist/src/a2a/index.d.ts.map +1 -0
  35. package/dist/src/a2a/index.js +24 -27
  36. package/dist/src/a2a/index.js.map +1 -0
  37. package/dist/src/a2a/streaming.d.ts +276 -3
  38. package/dist/src/a2a/streaming.d.ts.map +1 -0
  39. package/dist/src/a2a/streaming.js +255 -11
  40. package/dist/src/a2a/streaming.js.map +1 -0
  41. package/dist/src/a2a/task-lifecycle.d.ts +341 -20
  42. package/dist/src/a2a/task-lifecycle.d.ts.map +1 -0
  43. package/dist/src/a2a/task-lifecycle.js +327 -26
  44. package/dist/src/a2a/task-lifecycle.js.map +1 -0
  45. package/dist/src/budgetEnforcement.d.ts +93 -20
  46. package/dist/src/budgetEnforcement.d.ts.map +1 -0
  47. package/dist/src/budgetEnforcement.js +146 -31
  48. package/dist/src/budgetEnforcement.js.map +1 -0
  49. package/dist/src/circuit-breaker/index.d.ts +260 -10
  50. package/dist/src/circuit-breaker/index.d.ts.map +1 -0
  51. package/dist/src/circuit-breaker/index.js +226 -14
  52. package/dist/src/circuit-breaker/index.js.map +1 -0
  53. package/dist/src/cli.d.ts +1 -0
  54. package/dist/src/cli.d.ts.map +1 -0
  55. package/dist/src/cli.js +12 -11
  56. package/dist/src/cli.js.map +1 -0
  57. package/dist/src/compliance.d.ts +180 -3
  58. package/dist/src/compliance.d.ts.map +1 -0
  59. package/dist/src/compliance.js +114 -13
  60. package/dist/src/compliance.js.map +1 -0
  61. package/dist/src/conformance.d.ts +55 -2
  62. package/dist/src/conformance.d.ts.map +1 -0
  63. package/dist/src/conformance.js +124 -76
  64. package/dist/src/conformance.js.map +1 -0
  65. package/dist/src/conformanceProfiles.d.ts +68 -1
  66. package/dist/src/conformanceProfiles.d.ts.map +1 -0
  67. package/dist/src/conformanceProfiles.js +53 -1
  68. package/dist/src/conformanceProfiles.js.map +1 -0
  69. package/dist/src/deprecationRegistry.d.ts +82 -1
  70. package/dist/src/deprecationRegistry.d.ts.map +1 -0
  71. package/dist/src/deprecationRegistry.js +58 -7
  72. package/dist/src/deprecationRegistry.js.map +1 -0
  73. package/dist/src/discovery.d.ts +347 -65
  74. package/dist/src/discovery.d.ts.map +1 -0
  75. package/dist/src/discovery.js +130 -72
  76. package/dist/src/discovery.js.map +1 -0
  77. package/dist/src/envelope.d.ts +262 -9
  78. package/dist/src/envelope.d.ts.map +1 -0
  79. package/dist/src/envelope.js +179 -15
  80. package/dist/src/envelope.js.map +1 -0
  81. package/dist/src/errorRegistry.d.ts +163 -3
  82. package/dist/src/errorRegistry.d.ts.map +1 -0
  83. package/dist/src/errorRegistry.js +119 -3
  84. package/dist/src/errorRegistry.js.map +1 -0
  85. package/dist/src/fieldExtraction.d.ts +128 -27
  86. package/dist/src/fieldExtraction.d.ts.map +1 -0
  87. package/dist/src/fieldExtraction.js +100 -27
  88. package/dist/src/fieldExtraction.js.map +1 -0
  89. package/dist/src/flagResolver.d.ts +77 -10
  90. package/dist/src/flagResolver.d.ts.map +1 -0
  91. package/dist/src/flagResolver.js +22 -5
  92. package/dist/src/flagResolver.js.map +1 -0
  93. package/dist/src/flagSemantics.d.ts +80 -4
  94. package/dist/src/flagSemantics.d.ts.map +1 -0
  95. package/dist/src/flagSemantics.js +78 -11
  96. package/dist/src/flagSemantics.js.map +1 -0
  97. package/dist/src/health/index.d.ts +103 -9
  98. package/dist/src/health/index.d.ts.map +1 -0
  99. package/dist/src/health/index.js +75 -26
  100. package/dist/src/health/index.js.map +1 -0
  101. package/dist/src/index.d.ts +34 -23
  102. package/dist/src/index.d.ts.map +1 -0
  103. package/dist/src/index.js +40 -28
  104. package/dist/src/index.js.map +1 -0
  105. package/dist/src/mviProjection.d.ts +43 -6
  106. package/dist/src/mviProjection.d.ts.map +1 -0
  107. package/dist/src/mviProjection.js +32 -5
  108. package/dist/src/mviProjection.js.map +1 -0
  109. package/dist/src/native-loader.d.ts +49 -0
  110. package/dist/src/native-loader.d.ts.map +1 -0
  111. package/dist/src/native-loader.js +56 -0
  112. package/dist/src/native-loader.js.map +1 -0
  113. package/dist/src/problemDetails.d.ts +71 -4
  114. package/dist/src/problemDetails.d.ts.map +1 -0
  115. package/dist/src/problemDetails.js +27 -3
  116. package/dist/src/problemDetails.js.map +1 -0
  117. package/dist/src/shutdown/index.d.ts +103 -9
  118. package/dist/src/shutdown/index.d.ts.map +1 -0
  119. package/dist/src/shutdown/index.js +78 -12
  120. package/dist/src/shutdown/index.js.map +1 -0
  121. package/dist/src/tokenEstimator.d.ts +98 -11
  122. package/dist/src/tokenEstimator.d.ts.map +1 -0
  123. package/dist/src/tokenEstimator.js +91 -13
  124. package/dist/src/tokenEstimator.js.map +1 -0
  125. package/dist/src/types.d.ts +477 -11
  126. package/dist/src/types.d.ts.map +1 -0
  127. package/dist/src/types.js +76 -2
  128. package/dist/src/types.js.map +1 -0
  129. package/dist/src/validateEnvelope.d.ts +61 -2
  130. package/dist/src/validateEnvelope.d.ts.map +1 -0
  131. package/dist/src/validateEnvelope.js +81 -14
  132. package/dist/src/validateEnvelope.js.map +1 -0
  133. package/dist/tsconfig.build.tsbuildinfo +1 -0
  134. package/lafs.md +3 -4
  135. package/package.json +14 -12
  136. package/schemas/v1/agent-card.schema.json +0 -0
  137. package/schemas/v1/conformance-profiles.json +0 -0
  138. package/schemas/v1/context-ledger.schema.json +0 -0
  139. package/schemas/v1/discovery.schema.json +0 -0
  140. package/schemas/v1/envelope.schema.json +0 -0
  141. package/schemas/v1/error-registry.json +0 -0
  142. package/dist/src/mcpAdapter.d.ts +0 -28
  143. package/dist/src/mcpAdapter.js +0 -281
@@ -1,28 +1,73 @@
1
1
  /**
2
2
  * LAFS Health Check Module
3
3
  *
4
- * Provides health check endpoints for monitoring and orchestration
4
+ * Provides health check endpoints for monitoring and orchestration.
5
+ *
6
+ * @packageDocumentation
5
7
  */
8
+ /** Configuration for the {@link healthCheck} middleware. */
6
9
  export interface HealthCheckConfig {
10
+ /**
11
+ * URL path at which the health endpoint is mounted.
12
+ * @defaultValue '/health'
13
+ */
7
14
  path?: string;
15
+ /**
16
+ * Array of custom health check functions to run on each request.
17
+ * @defaultValue []
18
+ */
8
19
  checks?: HealthCheckFunction[];
9
20
  }
21
+ /**
22
+ * A function that performs a single health check.
23
+ *
24
+ * @remarks
25
+ * May be synchronous or asynchronous. Must return a {@link HealthCheckResult}
26
+ * describing the outcome.
27
+ */
10
28
  export type HealthCheckFunction = () => Promise<HealthCheckResult> | HealthCheckResult;
29
+ /** Result of an individual health check. */
11
30
  export interface HealthCheckResult {
31
+ /** Human-readable name identifying this check. */
12
32
  name: string;
33
+ /** Outcome status of the check. */
13
34
  status: 'ok' | 'warning' | 'error';
35
+ /**
36
+ * Optional descriptive message providing additional detail.
37
+ * @defaultValue undefined
38
+ */
14
39
  message?: string;
40
+ /**
41
+ * Execution duration of the check in milliseconds.
42
+ * @defaultValue undefined
43
+ */
15
44
  duration?: number;
16
45
  }
46
+ /** Aggregated health status returned by the health endpoint. */
17
47
  export interface HealthStatus {
48
+ /** Overall service health derived from individual check results. */
18
49
  status: 'healthy' | 'degraded' | 'unhealthy';
50
+ /** ISO-8601 timestamp of when the health check was performed. */
19
51
  timestamp: string;
52
+ /** LAFS package version. */
20
53
  version: string;
54
+ /** Server uptime in seconds since the middleware was initialised. */
21
55
  uptime: number;
56
+ /** Individual check results. */
22
57
  checks: HealthCheckResult[];
23
58
  }
24
59
  /**
25
- * Health check middleware for Express applications
60
+ * Health check middleware for Express applications.
61
+ *
62
+ * @remarks
63
+ * Runs all configured checks on each request, determines an overall status
64
+ * (`healthy`, `degraded`, or `unhealthy`), and responds with a JSON
65
+ * {@link HealthStatus} body. Returns HTTP 200 for healthy/degraded and 503
66
+ * for unhealthy. Two built-in checks (`envelopeValidation` and
67
+ * `tokenBudgets`) are always appended.
68
+ *
69
+ * @param config - Optional health check configuration
70
+ * @returns An Express-compatible middleware function that serves the health endpoint
26
71
  *
27
72
  * @example
28
73
  * ```typescript
@@ -45,9 +90,23 @@ export interface HealthStatus {
45
90
  * }));
46
91
  * ```
47
92
  */
48
- export declare function healthCheck(config?: HealthCheckConfig): (req: any, res: any) => Promise<void>;
93
+ export declare function healthCheck(config?: HealthCheckConfig): (_req: unknown, res: {
94
+ status: (code: number) => {
95
+ json: (body: unknown) => void;
96
+ };
97
+ }) => Promise<void>;
49
98
  /**
50
- * Create a database health check
99
+ * Create a health check function that verifies database connectivity.
100
+ *
101
+ * @remarks
102
+ * Wraps a caller-supplied connection check and returns a {@link HealthCheckResult}
103
+ * with status `'ok'` or `'error'` depending on whether the connection succeeds.
104
+ * Exceptions thrown by `checkConnection` are caught and reported as errors.
105
+ *
106
+ * @param config - Database check configuration
107
+ * @param config.checkConnection - Async function returning `true` if the database is reachable
108
+ * @param config.name - Display name for this check in health output
109
+ * @returns A {@link HealthCheckFunction} suitable for use in {@link HealthCheckConfig.checks}
51
110
  *
52
111
  * @example
53
112
  * ```typescript
@@ -65,7 +124,18 @@ export declare function createDatabaseHealthCheck(config: {
65
124
  name?: string;
66
125
  }): HealthCheckFunction;
67
126
  /**
68
- * Create an external service health check
127
+ * Create a health check function that probes an external HTTP service.
128
+ *
129
+ * @remarks
130
+ * Sends a `GET` request to the configured URL with an abort timeout. Returns
131
+ * status `'ok'` when the response is successful (HTTP 2xx) and `'error'`
132
+ * otherwise. Network failures and timeouts are caught and reported.
133
+ *
134
+ * @param config - External service check configuration
135
+ * @param config.name - Display name for this check in health output
136
+ * @param config.url - URL to probe for health status
137
+ * @param config.timeout - Request timeout in milliseconds
138
+ * @returns A {@link HealthCheckFunction} suitable for use in {@link HealthCheckConfig.checks}
69
139
  *
70
140
  * @example
71
141
  * ```typescript
@@ -82,16 +152,35 @@ export declare function createExternalServiceHealthCheck(config: {
82
152
  timeout?: number;
83
153
  }): HealthCheckFunction;
84
154
  /**
85
- * Liveness probe - basic check that service is running
155
+ * Liveness probe -- a minimal check confirming the process is running.
156
+ *
157
+ * @remarks
158
+ * Returns a 200 response with `{ status: 'alive', timestamp }`. Intended for
159
+ * Kubernetes liveness probes or equivalent orchestrator health checks that
160
+ * only need to verify the process has not crashed.
161
+ *
162
+ * @returns An Express-compatible middleware function
86
163
  *
87
164
  * @example
88
165
  * ```typescript
89
166
  * app.get('/health/live', livenessProbe());
90
167
  * ```
91
168
  */
92
- export declare function livenessProbe(): (req: any, res: any) => void;
169
+ export declare function livenessProbe(): (_req: unknown, res: {
170
+ status: (code: number) => {
171
+ json: (body: unknown) => void;
172
+ };
173
+ }) => void;
93
174
  /**
94
- * Readiness probe - check that service is ready to accept traffic
175
+ * Readiness probe -- verifies the service can accept traffic.
176
+ *
177
+ * @remarks
178
+ * Runs all configured health checks and responds with 200 (`ready`) when
179
+ * every check passes or 503 (`not ready`) when any check reports an error.
180
+ * Intended for Kubernetes readiness probes or load balancer health checks.
181
+ *
182
+ * @param config - Optional configuration with custom health check functions
183
+ * @returns An Express-compatible async middleware function
95
184
  *
96
185
  * @example
97
186
  * ```typescript
@@ -102,4 +191,9 @@ export declare function livenessProbe(): (req: any, res: any) => void;
102
191
  */
103
192
  export declare function readinessProbe(config?: {
104
193
  checks?: HealthCheckFunction[];
105
- }): (req: any, res: any) => Promise<void>;
194
+ }): (_req: unknown, res: {
195
+ status: (code: number) => {
196
+ json: (body: unknown) => void;
197
+ };
198
+ }) => Promise<void>;
199
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/health/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAChC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAEvF,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IA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B,MAAM,OAAO,EAAE,KAAK;IAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,CAAA;CAAE,UAM5F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE;IAAE,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAA;CAAO,IAE1E,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,mBAiCvE"}
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * LAFS Health Check Module
3
3
  *
4
- * Provides health check endpoints for monitoring and orchestration
4
+ * Provides health check endpoints for monitoring and orchestration.
5
+ *
6
+ * @packageDocumentation
5
7
  */
6
8
  import { createRequire } from 'node:module';
7
9
  const require = createRequire(import.meta.url);
@@ -13,7 +15,17 @@ catch {
13
15
  pkg = require('../../../package.json');
14
16
  }
15
17
  /**
16
- * Health check middleware for Express applications
18
+ * Health check middleware for Express applications.
19
+ *
20
+ * @remarks
21
+ * Runs all configured checks on each request, determines an overall status
22
+ * (`healthy`, `degraded`, or `unhealthy`), and responds with a JSON
23
+ * {@link HealthStatus} body. Returns HTTP 200 for healthy/degraded and 503
24
+ * for unhealthy. Two built-in checks (`envelopeValidation` and
25
+ * `tokenBudgets`) are always appended.
26
+ *
27
+ * @param config - Optional health check configuration
28
+ * @returns An Express-compatible middleware function that serves the health endpoint
17
29
  *
18
30
  * @example
19
31
  * ```typescript
@@ -37,9 +49,9 @@ catch {
37
49
  * ```
38
50
  */
39
51
  export function healthCheck(config = {}) {
40
- const { path = '/health', checks = [] } = config;
52
+ const { path: _path = '/health', checks = [] } = config;
41
53
  const startTime = Date.now();
42
- return async (req, res) => {
54
+ return async (_req, res) => {
43
55
  const timestamp = new Date().toISOString();
44
56
  const checkResults = [];
45
57
  // Run all health checks
@@ -55,22 +67,22 @@ export function healthCheck(config = {}) {
55
67
  name: 'unknown',
56
68
  status: 'error',
57
69
  message: error instanceof Error ? error.message : 'Check failed',
58
- duration: Date.now() - start
70
+ duration: Date.now() - start,
59
71
  });
60
72
  }
61
73
  }
62
74
  // Add default checks
63
75
  checkResults.push({
64
76
  name: 'envelopeValidation',
65
- status: 'ok'
77
+ status: 'ok',
66
78
  });
67
79
  checkResults.push({
68
80
  name: 'tokenBudgets',
69
- status: 'ok'
81
+ status: 'ok',
70
82
  });
71
83
  // Determine overall status
72
- const hasErrors = checkResults.some(c => c.status === 'error');
73
- const hasWarnings = checkResults.some(c => c.status === 'warning');
84
+ const hasErrors = checkResults.some((c) => c.status === 'error');
85
+ const hasWarnings = checkResults.some((c) => c.status === 'warning');
74
86
  const status = hasErrors
75
87
  ? 'unhealthy'
76
88
  : hasWarnings
@@ -81,14 +93,24 @@ export function healthCheck(config = {}) {
81
93
  timestamp,
82
94
  version: pkg.version,
83
95
  uptime: Math.floor((Date.now() - startTime) / 1000),
84
- checks: checkResults
96
+ checks: checkResults,
85
97
  };
86
98
  const statusCode = status === 'healthy' ? 200 : status === 'degraded' ? 200 : 503;
87
99
  res.status(statusCode).json(health);
88
100
  };
89
101
  }
90
102
  /**
91
- * Create a database health check
103
+ * Create a health check function that verifies database connectivity.
104
+ *
105
+ * @remarks
106
+ * Wraps a caller-supplied connection check and returns a {@link HealthCheckResult}
107
+ * with status `'ok'` or `'error'` depending on whether the connection succeeds.
108
+ * Exceptions thrown by `checkConnection` are caught and reported as errors.
109
+ *
110
+ * @param config - Database check configuration
111
+ * @param config.checkConnection - Async function returning `true` if the database is reachable
112
+ * @param config.name - Display name for this check in health output
113
+ * @returns A {@link HealthCheckFunction} suitable for use in {@link HealthCheckConfig.checks}
92
114
  *
93
115
  * @example
94
116
  * ```typescript
@@ -108,20 +130,31 @@ export function createDatabaseHealthCheck(config) {
108
130
  return {
109
131
  name: config.name || 'database',
110
132
  status: isConnected ? 'ok' : 'error',
111
- message: isConnected ? 'Connected' : 'Connection failed'
133
+ message: isConnected ? 'Connected' : 'Connection failed',
112
134
  };
113
135
  }
114
136
  catch (error) {
115
137
  return {
116
138
  name: config.name || 'database',
117
139
  status: 'error',
118
- message: error instanceof Error ? error.message : 'Database check failed'
140
+ message: error instanceof Error ? error.message : 'Database check failed',
119
141
  };
120
142
  }
121
143
  };
122
144
  }
123
145
  /**
124
- * Create an external service health check
146
+ * Create a health check function that probes an external HTTP service.
147
+ *
148
+ * @remarks
149
+ * Sends a `GET` request to the configured URL with an abort timeout. Returns
150
+ * status `'ok'` when the response is successful (HTTP 2xx) and `'error'`
151
+ * otherwise. Network failures and timeouts are caught and reported.
152
+ *
153
+ * @param config - External service check configuration
154
+ * @param config.name - Display name for this check in health output
155
+ * @param config.url - URL to probe for health status
156
+ * @param config.timeout - Request timeout in milliseconds
157
+ * @returns A {@link HealthCheckFunction} suitable for use in {@link HealthCheckConfig.checks}
125
158
  *
126
159
  * @example
127
160
  * ```typescript
@@ -139,14 +172,14 @@ export function createExternalServiceHealthCheck(config) {
139
172
  const controller = new AbortController();
140
173
  const timeout = setTimeout(() => controller.abort(), config.timeout || 5000);
141
174
  const response = await fetch(config.url, {
142
- signal: controller.signal
175
+ signal: controller.signal,
143
176
  });
144
177
  clearTimeout(timeout);
145
178
  return {
146
179
  name: config.name,
147
180
  status: response.ok ? 'ok' : 'error',
148
181
  message: response.ok ? 'Service healthy' : `HTTP ${response.status}`,
149
- duration: Date.now() - start
182
+ duration: Date.now() - start,
150
183
  };
151
184
  }
152
185
  catch (error) {
@@ -154,13 +187,20 @@ export function createExternalServiceHealthCheck(config) {
154
187
  name: config.name,
155
188
  status: 'error',
156
189
  message: error instanceof Error ? error.message : 'Service unreachable',
157
- duration: Date.now() - start
190
+ duration: Date.now() - start,
158
191
  };
159
192
  }
160
193
  };
161
194
  }
162
195
  /**
163
- * Liveness probe - basic check that service is running
196
+ * Liveness probe -- a minimal check confirming the process is running.
197
+ *
198
+ * @remarks
199
+ * Returns a 200 response with `{ status: 'alive', timestamp }`. Intended for
200
+ * Kubernetes liveness probes or equivalent orchestrator health checks that
201
+ * only need to verify the process has not crashed.
202
+ *
203
+ * @returns An Express-compatible middleware function
164
204
  *
165
205
  * @example
166
206
  * ```typescript
@@ -168,15 +208,23 @@ export function createExternalServiceHealthCheck(config) {
168
208
  * ```
169
209
  */
170
210
  export function livenessProbe() {
171
- return (req, res) => {
211
+ return (_req, res) => {
172
212
  res.status(200).json({
173
213
  status: 'alive',
174
- timestamp: new Date().toISOString()
214
+ timestamp: new Date().toISOString(),
175
215
  });
176
216
  };
177
217
  }
178
218
  /**
179
- * Readiness probe - check that service is ready to accept traffic
219
+ * Readiness probe -- verifies the service can accept traffic.
220
+ *
221
+ * @remarks
222
+ * Runs all configured health checks and responds with 200 (`ready`) when
223
+ * every check passes or 503 (`not ready`) when any check reports an error.
224
+ * Intended for Kubernetes readiness probes or load balancer health checks.
225
+ *
226
+ * @param config - Optional configuration with custom health check functions
227
+ * @returns An Express-compatible async middleware function
180
228
  *
181
229
  * @example
182
230
  * ```typescript
@@ -186,7 +234,7 @@ export function livenessProbe() {
186
234
  * ```
187
235
  */
188
236
  export function readinessProbe(config = {}) {
189
- return async (req, res) => {
237
+ return async (_req, res) => {
190
238
  const checkResults = [];
191
239
  if (config.checks) {
192
240
  for (const check of config.checks) {
@@ -198,23 +246,24 @@ export function readinessProbe(config = {}) {
198
246
  checkResults.push({
199
247
  name: 'unknown',
200
248
  status: 'error',
201
- message: error instanceof Error ? error.message : 'Check failed'
249
+ message: error instanceof Error ? error.message : 'Check failed',
202
250
  });
203
251
  }
204
252
  }
205
253
  }
206
- const hasErrors = checkResults.some(c => c.status === 'error');
254
+ const hasErrors = checkResults.some((c) => c.status === 'error');
207
255
  if (hasErrors) {
208
256
  res.status(503).json({
209
257
  status: 'not ready',
210
- checks: checkResults
258
+ checks: checkResults,
211
259
  });
212
260
  }
213
261
  else {
214
262
  res.status(200).json({
215
263
  status: 'ready',
216
- checks: checkResults
264
+ checks: checkResults,
217
265
  });
218
266
  }
219
267
  };
220
268
  }
269
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/health/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,IAAI,GAAwB,CAAC;AAC7B,IAAI,CAAC;IACH,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACtC,CAAC;AAAC,MAAM,CAAC;IACP,GAAG,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACzC,CAAC;AAiED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,WAAW,CAAC,SAA4B,EAAE;IACxD,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAExD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,OAAO,KAAK,EACV,IAAa,EACb,GAAoE,EACpE,EAAE;QACF,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,YAAY,GAAwB,EAAE,CAAC;QAE7C,wBAAwB;QACxB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,KAAK,EAAE,CAAC;gBAC7B,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;gBACrC,Y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pE,EAAE;QACF,MAAM,YAAY,GAAwB,EAAE,CAAC;QAE7C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClC,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,MAAM,KAAK,EAAE,CAAC;oBAC7B,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC5B,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,YAAY,CAAC,IAAI,CAAC;wBAChB,IAAI,EAAE,SAAS;wBACf,MAAM,EAAE,OAAO;wBACf,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc;qBACjE,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC;QAEjE,IAAI,SAAS,EAAE,CAAC;YACd,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,MAAM,EAAE,WAAW;gBACnB,MAAM,EAAE,YAAY;aACrB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE,YAAY;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1,24 +1,35 @@
1
- export * from "./types.js";
2
- export * from "./errorRegistry.js";
3
- export * from "./deprecationRegistry.js";
4
- export * from "./validateEnvelope.js";
5
- export * from "./envelope.js";
6
- export * from "./flagSemantics.js";
7
- export * from "./fieldExtraction.js";
8
- export * from "./flagResolver.js";
9
- export * from "./mviProjection.js";
10
- export * from "./conformance.js";
11
- export * from "./conformanceProfiles.js";
12
- export * from "./compliance.js";
13
- export * from "./tokenEstimator.js";
14
- export * from "./budgetEnforcement.js";
15
- export * from "./mcpAdapter.js";
16
- export * from "./discovery.js";
17
- export { lafsErrorToProblemDetails, PROBLEM_DETAILS_CONTENT_TYPE } from './problemDetails.js';
1
+ /**
2
+ * LAFS (LLM-Agent-First Specification) TypeScript SDK.
3
+ *
4
+ * @packageDocumentation
5
+ *
6
+ * @remarks
7
+ * This is the main entry point for the `@cleocode/lafs` package. It re-exports all
8
+ * public modules including envelope creation, validation, conformance checking,
9
+ * error registry, flag resolution, MVI projection, A2A integration, and operational
10
+ * primitives (health, shutdown, circuit breaker).
11
+ */
12
+ export type { Artifact, BuildLafsExtensionOptions, CreateTaskOptions, DataPart, ExtensionNegotiationMiddlewareOptions, ExtensionNegotiationResult, FilePart, JSONRPCErrorResponse, LafsA2AConfig, LafsExtensionParams, LafsSendMessageParams, ListTasksOptions, ListTasksResult, Message, MessageSendConfiguration, Part, PushNotificationConfig, PushNotificationDeliveryResult, PushTransport, SendMessageResponse, SendMessageSuccessResponse, StreamIteratorOptions, Task, TaskArtifactUpdateEvent, TaskState, TaskStatus, TaskStatusUpdateEvent, TaskStreamEvent, TextPart, } from './a2a/index.js';
13
+ export { A2A_EXTENSIONS_HEADER, AGENT_CARD_PATH, attachLafsEnvelope, buildLafsExtension, createFileArtifact, createLafsArtifact, createTextArtifact, ExtensionSupportRequiredError, extensionNegotiationMiddleware, formatExtensionsHeader, getExtensionParams, HTTP_EXTENSION_HEADER, INTERRUPTED_STATES, InvalidStateTransitionError, isExtensionRequired, isInterruptedState, isTerminalState, isValidTransition, LAFS_EXTENSION_URI, LafsA2AResult, negotiateExtensions, PushNotificationConfigStore, PushNotificationDispatcher, parseExtensionsHeader, streamTaskEvents, TaskArtifactAssembler, TaskEventBus, TaskImmutabilityError, TaskManager, TaskNotFoundError, TaskRefinementError, TERMINAL_STATES, VALID_TRANSITIONS, } from './a2a/index.js';
14
+ export * from './budgetEnforcement.js';
15
+ export * from './circuit-breaker/index.js';
16
+ export * from './compliance.js';
17
+ export * from './conformance.js';
18
+ export * from './conformanceProfiles.js';
19
+ export * from './deprecationRegistry.js';
20
+ export * from './discovery.js';
21
+ export * from './envelope.js';
22
+ export * from './errorRegistry.js';
23
+ export * from './fieldExtraction.js';
24
+ export * from './flagResolver.js';
25
+ export * from './flagSemantics.js';
26
+ export * from './health/index.js';
27
+ export * from './mviProjection.js';
28
+ export { isNativeAvailable } from './native-loader.js';
18
29
  export type { LafsProblemDetails } from './problemDetails.js';
19
- export * from "./health/index.js";
20
- export * from "./shutdown/index.js";
21
- export * from "./circuit-breaker/index.js";
22
- export { LafsA2AResult, createLafsArtifact, createTextArtifact, createFileArtifact, isExtensionRequired, getExtensionParams, AGENT_CARD_PATH, HTTP_EXTENSION_HEADER, LAFS_EXTENSION_URI, A2A_EXTENSIONS_HEADER, parseExtensionsHeader, negotiateExtensions, formatExtensionsHeader, buildLafsExtension, ExtensionSupportRequiredError, extensionNegotiationMiddleware, TERMINAL_STATES, INTERRUPTED_STATES, VALID_TRANSITIONS, isValidTransition, isTerminalState, isInterruptedState, InvalidStateTransitionError, TaskImmutabilityError, TaskNotFoundError, TaskRefinementError, TaskManager, attachLafsEnvelope, TaskEventBus, PushNotificationConfigStore, PushNotificationDispatcher, TaskArtifactAssembler, streamTaskEvents, } from "./a2a/index.js";
23
- export type { LafsA2AConfig, LafsSendMessageParams, LafsExtensionParams, ExtensionNegotiationResult, BuildLafsExtensionOptions, ExtensionNegotiationMiddlewareOptions, CreateTaskOptions, ListTasksOptions, ListTasksResult, TaskStreamEvent, StreamIteratorOptions, PushNotificationDeliveryResult, PushTransport, } from "./a2a/index.js";
24
- export type { Task, TaskState, TaskStatus, Artifact, Part, Message, PushNotificationConfig, MessageSendConfiguration, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, SendMessageResponse, SendMessageSuccessResponse, JSONRPCErrorResponse, TextPart, DataPart, FilePart, } from "./a2a/index.js";
30
+ export { lafsErrorToProblemDetails, PROBLEM_DETAILS_CONTENT_TYPE } from './problemDetails.js';
31
+ export * from './shutdown/index.js';
32
+ export * from './tokenEstimator.js';
33
+ export * from './types.js';
34
+ export * from './validateEnvelope.js';
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,YAAY,EACV,QAAQ,EACR,yBAAyB,EACzB,iBAAiB,EACjB,QAAQ,EACR,qCAAqC,EACrC,0BAA0B,EAC1B,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,OAAO,EACP,wBAAwB,EACxB,IAAI,EACJ,sBAAsB,EACtB,8BAA8B,EAC9B,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACrB,IAAI,EACJ,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,eAAe,EACf,QAAQ,GACT,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EAEjB,kBAAkB,EAElB,aAAa,EACb,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EAErB,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EAEnB,eAAe,EACf,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAC9F,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,34 +1,46 @@
1
- export * from "./types.js";
2
- export * from "./errorRegistry.js";
3
- export * from "./deprecationRegistry.js";
4
- export * from "./validateEnvelope.js";
5
- export * from "./envelope.js";
6
- export * from "./flagSemantics.js";
7
- export * from "./fieldExtraction.js";
8
- export * from "./flagResolver.js";
9
- export * from "./mviProjection.js";
10
- export * from "./conformance.js";
11
- export * from "./conformanceProfiles.js";
12
- export * from "./compliance.js";
13
- export * from "./tokenEstimator.js";
14
- export * from "./budgetEnforcement.js";
15
- export * from "./mcpAdapter.js";
16
- export * from "./discovery.js";
17
- export { lafsErrorToProblemDetails, PROBLEM_DETAILS_CONTENT_TYPE } from './problemDetails.js';
18
- // Operations & Reliability
19
- export * from "./health/index.js";
20
- export * from "./shutdown/index.js";
21
- export * from "./circuit-breaker/index.js";
1
+ /**
2
+ * LAFS (LLM-Agent-First Specification) TypeScript SDK.
3
+ *
4
+ * @packageDocumentation
5
+ *
6
+ * @remarks
7
+ * This is the main entry point for the `@cleocode/lafs` package. It re-exports all
8
+ * public modules including envelope creation, validation, conformance checking,
9
+ * error registry, flag resolution, MVI projection, A2A integration, and operational
10
+ * primitives (health, shutdown, circuit breaker).
11
+ */
22
12
  // A2A Integration
23
13
  // Explicitly re-export to avoid naming conflicts with discovery types
24
14
  // (AgentCard, AgentSkill, AgentCapabilities, AgentExtension).
25
15
  // For full A2A types, import from '@cleocode/lafs/a2a'.
26
- export {
27
- // Bridge
28
- LafsA2AResult, createLafsArtifact, createTextArtifact, createFileArtifact, isExtensionRequired, getExtensionParams, AGENT_CARD_PATH, HTTP_EXTENSION_HEADER,
16
+ export { A2A_EXTENSIONS_HEADER, AGENT_CARD_PATH, attachLafsEnvelope, buildLafsExtension, createFileArtifact, createLafsArtifact, createTextArtifact, ExtensionSupportRequiredError, extensionNegotiationMiddleware, formatExtensionsHeader, getExtensionParams, HTTP_EXTENSION_HEADER, INTERRUPTED_STATES, InvalidStateTransitionError, isExtensionRequired, isInterruptedState, isTerminalState, isValidTransition,
29
17
  // Extensions (T098)
30
- LAFS_EXTENSION_URI, A2A_EXTENSIONS_HEADER, parseExtensionsHeader, negotiateExtensions, formatExtensionsHeader, buildLafsExtension, ExtensionSupportRequiredError, extensionNegotiationMiddleware,
31
- // Task Lifecycle (T099)
32
- TERMINAL_STATES, INTERRUPTED_STATES, VALID_TRANSITIONS, isValidTransition, isTerminalState, isInterruptedState, InvalidStateTransitionError, TaskImmutabilityError, TaskNotFoundError, TaskRefinementError, TaskManager, attachLafsEnvelope,
18
+ LAFS_EXTENSION_URI,
19
+ // Bridge
20
+ LafsA2AResult, negotiateExtensions, PushNotificationConfigStore, PushNotificationDispatcher, parseExtensionsHeader, streamTaskEvents, TaskArtifactAssembler,
33
21
  // Streaming and Async (T101)
34
- TaskEventBus, PushNotificationConfigStore, PushNotificationDispatcher, TaskArtifactAssembler, streamTaskEvents, } from "./a2a/index.js";
22
+ TaskEventBus, TaskImmutabilityError, TaskManager, TaskNotFoundError, TaskRefinementError,
23
+ // Task Lifecycle (T099)
24
+ TERMINAL_STATES, VALID_TRANSITIONS, } from './a2a/index.js';
25
+ export * from './budgetEnforcement.js';
26
+ export * from './circuit-breaker/index.js';
27
+ export * from './compliance.js';
28
+ export * from './conformance.js';
29
+ export * from './conformanceProfiles.js';
30
+ export * from './deprecationRegistry.js';
31
+ export * from './discovery.js';
32
+ export * from './envelope.js';
33
+ export * from './errorRegistry.js';
34
+ export * from './fieldExtraction.js';
35
+ export * from './flagResolver.js';
36
+ export * from './flagSemantics.js';
37
+ // Operations & Reliability
38
+ export * from './health/index.js';
39
+ export * from './mviProjection.js';
40
+ export { isNativeAvailable } from './native-loader.js';
41
+ export { lafsErrorToProblemDetails, PROBLEM_DETAILS_CONTENT_TYPE } from './problemDetails.js';
42
+ export * from './shutdown/index.js';
43
+ export * from './tokenEstimator.js';
44
+ export * from './types.js';
45
+ export * from './validateEnvelope.js';
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkCH,kBAAkB;AAClB,sEAAsE;AACtE,8DAA8D;AAC9D,wDAAwD;AACxD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB;AACjB,oBAAoB;AACpB,kBAAkB;AAClB,SAAS;AACT,aAAa,EACb,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB;AACrB,6BAA6B;AAC7B,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,mBAAmB;AACnB,wBAAwB;AACxB,eAAe,EACf,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,2BAA2B;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAC9F,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
@@ -1,19 +1,56 @@
1
1
  /**
2
2
  * MVI-aware envelope projection.
3
+ *
3
4
  * Strips fields based on declared MVI level to reduce token cost.
4
- * At 'minimal': ~38 tokens per error (vs ~162 at 'full').
5
+ * At `'minimal'`: approximately 38 tokens per error (vs approximately 162 at `'full'`).
6
+ *
7
+ * @remarks
8
+ * Projection is applied after field extraction and before serialization. The four
9
+ * MVI levels control which envelope fields are included in the output:
10
+ * - `'minimal'`: only fields required for agent control flow
11
+ * - `'standard'`: all commonly useful fields (current default)
12
+ * - `'full'` / `'custom'`: complete envelope, no stripping
13
+ *
14
+ * @since 1.5.0
5
15
  */
6
16
  import type { LAFSEnvelope, MVILevel } from './types.js';
7
17
  /**
8
18
  * Project an envelope to the declared MVI verbosity level.
9
- * - 'minimal': Only fields required for agent control flow
10
- * - 'standard': All commonly useful fields (current default behavior)
11
- * - 'full': Complete echo-back including request parameters
12
- * - 'custom': No projection (controlled by _fields)
19
+ *
20
+ * @param envelope - The full LAFS envelope to project
21
+ * @param mviLevel - Override MVI level; falls back to `envelope._meta.mvi`, then `'standard'`
22
+ * @returns A plain object containing only the fields appropriate for the resolved MVI level
23
+ *
24
+ * @remarks
25
+ * MVI levels control projection behavior:
26
+ * - `'minimal'`: only fields required for agent control flow (success, error code, retry info)
27
+ * - `'standard'`: all commonly useful fields (current default behavior)
28
+ * - `'full'`: complete echo-back including request parameters
29
+ * - `'custom'`: no projection (controlled by field extraction layer)
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const minimal = projectEnvelope(envelope, 'minimal');
34
+ * // minimal contains only: success, _meta (requestId, contextVersion), result/error
35
+ * ```
13
36
  */
14
37
  export declare function projectEnvelope(envelope: LAFSEnvelope, mviLevel?: MVILevel): Record<string, unknown>;
15
38
  /**
16
39
  * Estimate token count for a projected envelope.
17
- * Uses simple heuristic: 1 token per ~4 characters of JSON.
40
+ *
41
+ * @param projected - The projected envelope object to estimate
42
+ * @returns The estimated token count based on JSON serialization length
43
+ *
44
+ * @remarks
45
+ * Uses a simple heuristic of 1 token per approximately 4 characters of
46
+ * JSON-serialized output. This is an approximation suitable for budget
47
+ * enforcement, not an exact tokenizer count.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const tokens = estimateProjectedTokens(projectEnvelope(envelope, 'minimal'));
52
+ * // tokens ~= Math.ceil(JSON.stringify(projected).length / 4)
53
+ * ```
18
54
  */
19
55
  export declare function estimateProjectedTokens(projected: Record<string, unknown>): number;
56
+ //# sourceMappingURL=mviProjection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mviProjection.d.ts","sourceRoot":"","sources":["../../src/mviProjection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,YAAY,EAAuB,QAAQ,EAAE,MAAM,YAAY,CAAC;AAa9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,QAAQ,GAClB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB;AAoGD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAGlF"}