@cleocode/lafs 2026.4.0 → 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.
- package/README.md +97 -68
- package/dist/src/a2a/bindings/grpc.d.ts +117 -11
- package/dist/src/a2a/bindings/grpc.d.ts.map +1 -1
- package/dist/src/a2a/bindings/grpc.js +79 -8
- package/dist/src/a2a/bindings/grpc.js.map +1 -1
- package/dist/src/a2a/bindings/http.d.ts +129 -14
- package/dist/src/a2a/bindings/http.d.ts.map +1 -1
- package/dist/src/a2a/bindings/http.js +93 -12
- package/dist/src/a2a/bindings/http.js.map +1 -1
- package/dist/src/a2a/bindings/index.d.ts +80 -7
- package/dist/src/a2a/bindings/index.d.ts.map +1 -1
- package/dist/src/a2a/bindings/index.js +69 -2
- package/dist/src/a2a/bindings/index.js.map +1 -1
- package/dist/src/a2a/bindings/jsonrpc.d.ts +193 -9
- package/dist/src/a2a/bindings/jsonrpc.d.ts.map +1 -1
- package/dist/src/a2a/bindings/jsonrpc.js +152 -9
- package/dist/src/a2a/bindings/jsonrpc.js.map +1 -1
- package/dist/src/a2a/bridge.d.ts +232 -37
- package/dist/src/a2a/bridge.d.ts.map +1 -1
- package/dist/src/a2a/bridge.js +172 -24
- package/dist/src/a2a/bridge.js.map +1 -1
- package/dist/src/a2a/extensions.d.ts +221 -12
- package/dist/src/a2a/extensions.d.ts.map +1 -1
- package/dist/src/a2a/extensions.js +175 -11
- package/dist/src/a2a/extensions.js.map +1 -1
- package/dist/src/a2a/index.d.ts +2 -0
- package/dist/src/a2a/index.d.ts.map +1 -1
- package/dist/src/a2a/index.js +2 -0
- package/dist/src/a2a/index.js.map +1 -1
- package/dist/src/a2a/streaming.d.ts +274 -2
- package/dist/src/a2a/streaming.d.ts.map +1 -1
- package/dist/src/a2a/streaming.js +245 -2
- package/dist/src/a2a/streaming.js.map +1 -1
- package/dist/src/a2a/task-lifecycle.d.ts +339 -19
- package/dist/src/a2a/task-lifecycle.d.ts.map +1 -1
- package/dist/src/a2a/task-lifecycle.js +302 -19
- package/dist/src/a2a/task-lifecycle.js.map +1 -1
- package/dist/src/budgetEnforcement.d.ts +88 -14
- package/dist/src/budgetEnforcement.d.ts.map +1 -1
- package/dist/src/budgetEnforcement.js +132 -19
- package/dist/src/budgetEnforcement.js.map +1 -1
- package/dist/src/circuit-breaker/index.d.ts +254 -9
- package/dist/src/circuit-breaker/index.d.ts.map +1 -1
- package/dist/src/circuit-breaker/index.js +218 -9
- package/dist/src/circuit-breaker/index.js.map +1 -1
- package/dist/src/compliance.d.ts +176 -0
- package/dist/src/compliance.d.ts.map +1 -1
- package/dist/src/compliance.js +100 -0
- package/dist/src/compliance.js.map +1 -1
- package/dist/src/conformance.d.ts +52 -0
- package/dist/src/conformance.d.ts.map +1 -1
- package/dist/src/conformance.js +41 -0
- package/dist/src/conformance.js.map +1 -1
- package/dist/src/conformanceProfiles.d.ts +66 -0
- package/dist/src/conformanceProfiles.d.ts.map +1 -1
- package/dist/src/conformanceProfiles.js +51 -0
- package/dist/src/conformanceProfiles.js.map +1 -1
- package/dist/src/deprecationRegistry.d.ts +80 -0
- package/dist/src/deprecationRegistry.d.ts.map +1 -1
- package/dist/src/deprecationRegistry.js +50 -0
- package/dist/src/deprecationRegistry.js.map +1 -1
- package/dist/src/discovery.d.ts +344 -63
- package/dist/src/discovery.d.ts.map +1 -1
- package/dist/src/discovery.js +67 -13
- package/dist/src/discovery.js.map +1 -1
- package/dist/src/envelope.d.ts +252 -0
- package/dist/src/envelope.d.ts.map +1 -1
- package/dist/src/envelope.js +165 -0
- package/dist/src/envelope.js.map +1 -1
- package/dist/src/errorRegistry.d.ts +159 -0
- package/dist/src/errorRegistry.d.ts.map +1 -1
- package/dist/src/errorRegistry.js +115 -0
- package/dist/src/errorRegistry.js.map +1 -1
- package/dist/src/fieldExtraction.d.ts +125 -25
- package/dist/src/fieldExtraction.d.ts.map +1 -1
- package/dist/src/fieldExtraction.js +85 -16
- package/dist/src/fieldExtraction.js.map +1 -1
- package/dist/src/flagResolver.d.ts +75 -9
- package/dist/src/flagResolver.d.ts.map +1 -1
- package/dist/src/flagResolver.js +20 -4
- package/dist/src/flagResolver.js.map +1 -1
- package/dist/src/flagSemantics.d.ts +76 -1
- package/dist/src/flagSemantics.d.ts.map +1 -1
- package/dist/src/flagSemantics.js +66 -0
- package/dist/src/flagSemantics.js.map +1 -1
- package/dist/src/health/index.d.ts +87 -6
- package/dist/src/health/index.d.ts.map +1 -1
- package/dist/src/health/index.js +54 -6
- package/dist/src/health/index.js.map +1 -1
- package/dist/src/index.d.ts +12 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mviProjection.d.ts +42 -6
- package/dist/src/mviProjection.d.ts.map +1 -1
- package/dist/src/mviProjection.js +31 -5
- package/dist/src/mviProjection.js.map +1 -1
- package/dist/src/native-loader.d.ts +49 -0
- package/dist/src/native-loader.d.ts.map +1 -0
- package/dist/src/native-loader.js +56 -0
- package/dist/src/native-loader.js.map +1 -0
- package/dist/src/problemDetails.d.ts +70 -4
- package/dist/src/problemDetails.d.ts.map +1 -1
- package/dist/src/problemDetails.js +21 -3
- package/dist/src/problemDetails.js.map +1 -1
- package/dist/src/shutdown/index.d.ts +96 -7
- package/dist/src/shutdown/index.d.ts.map +1 -1
- package/dist/src/shutdown/index.js +72 -7
- package/dist/src/shutdown/index.js.map +1 -1
- package/dist/src/tokenEstimator.d.ts +97 -11
- package/dist/src/tokenEstimator.d.ts.map +1 -1
- package/dist/src/tokenEstimator.js +90 -11
- package/dist/src/tokenEstimator.js.map +1 -1
- package/dist/src/types.d.ts +467 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +64 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/validateEnvelope.d.ts +59 -1
- package/dist/src/validateEnvelope.d.ts.map +1 -1
- package/dist/src/validateEnvelope.js +75 -9
- package/dist/src/validateEnvelope.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/lafs.md +3 -4
- package/package.json +6 -3
- package/dist/src/mcpAdapter.d.ts +0 -29
- package/dist/src/mcpAdapter.d.ts.map +0 -1
- package/dist/src/mcpAdapter.js +0 -286
- package/dist/src/mcpAdapter.js.map +0 -1
- package/schemas/v1/conformance-profiles.d.ts +0 -15
- package/schemas/v1/envelope.schema.d.ts +0 -14
- package/schemas/v1/error-registry.d.ts +0 -24
|
@@ -1,10 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flag semantics for LAFS output format resolution.
|
|
3
|
+
*
|
|
4
|
+
* Implements the precedence chain defined in LAFS spec sections 5.1-5.3:
|
|
5
|
+
* explicit flag > project config > user config > TTY detection > default (json).
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This module is the single-layer resolver for format flags. For cross-layer
|
|
9
|
+
* resolution that also includes field extraction, use {@link resolveFlags} from
|
|
10
|
+
* `flagResolver.ts`.
|
|
11
|
+
*
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
*/
|
|
1
14
|
import { getRegistryCode } from './errorRegistry.js';
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown when LAFS flag validation fails.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Wraps a registered LAFS error code with category and retryability information
|
|
20
|
+
* looked up from the error registry. The most common error is `E_FORMAT_CONFLICT`
|
|
21
|
+
* when `--human` and `--json` are used together.
|
|
22
|
+
*/
|
|
2
23
|
export class LAFSFlagError extends Error {
|
|
24
|
+
/** The LAFS error code (e.g. `'E_FORMAT_CONFLICT'`). */
|
|
3
25
|
code;
|
|
26
|
+
/** The error category resolved from the error registry. */
|
|
4
27
|
category;
|
|
28
|
+
/** Whether the operation that produced this error can be retried. */
|
|
5
29
|
retryable;
|
|
30
|
+
/** Milliseconds to wait before retrying, or `null` if not applicable. */
|
|
6
31
|
retryAfterMs;
|
|
32
|
+
/** Additional structured details about the error. */
|
|
7
33
|
details;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new LAFSFlagError.
|
|
36
|
+
*
|
|
37
|
+
* @param code - A registered LAFS error code (e.g. `'E_FORMAT_CONFLICT'`)
|
|
38
|
+
* @param message - Human-readable description of the error
|
|
39
|
+
* @param details - Optional structured details to attach to the error
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Looks up the error code in the LAFS error registry to populate
|
|
43
|
+
* `category` and `retryable`. Falls back to `'CONTRACT'` category
|
|
44
|
+
* and non-retryable if the code is not found.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* throw new LAFSFlagError(
|
|
49
|
+
* 'E_FORMAT_CONFLICT',
|
|
50
|
+
* 'Cannot combine --human and --json.',
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
8
54
|
constructor(code, message, details = {}) {
|
|
9
55
|
super(message);
|
|
10
56
|
this.name = 'LAFSFlagError';
|
|
@@ -16,6 +62,26 @@ export class LAFSFlagError extends Error {
|
|
|
16
62
|
this.details = details;
|
|
17
63
|
}
|
|
18
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Resolve the output format from flag inputs using the LAFS precedence chain.
|
|
67
|
+
*
|
|
68
|
+
* @param input - The flag inputs including explicit flags, project/user defaults, and TTY state
|
|
69
|
+
* @returns The resolved format, its source layer, and quiet mode status
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Precedence (highest to lowest): explicit `requestedFormat` > `--human`/`--json` flag >
|
|
73
|
+
* project default > user default > TTY detection > protocol default (`'json'`).
|
|
74
|
+
* Throws `LAFSFlagError` with code `E_FORMAT_CONFLICT` if both `--human` and `--json`
|
|
75
|
+
* are set simultaneously.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const resolution = resolveOutputFormat({ humanFlag: true });
|
|
80
|
+
* // => { format: 'human', source: 'flag', quiet: false }
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @throws {@link LAFSFlagError} When `humanFlag` and `jsonFlag` are both truthy.
|
|
84
|
+
*/
|
|
19
85
|
export function resolveOutputFormat(input) {
|
|
20
86
|
if (input.humanFlag && input.jsonFlag) {
|
|
21
87
|
throw new LAFSFlagError('E_FORMAT_CONFLICT', 'Cannot combine --human and --json in the same invocation.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flagSemantics.js","sourceRoot":"","sources":["../../src/flagSemantics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"flagSemantics.js","sourceRoot":"","sources":["../../src/flagSemantics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAmBrD;;;;;;;GAOG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,wDAAwD;IACxD,IAAI,CAAS;IACb,2DAA2D;IAC3D,QAAQ,CAAoB;IAC5B,qEAAqE;IACrE,SAAS,CAAU;IACnB,yEAAyE;IACzE,YAAY,CAAgB;IAC5B,qDAAqD;IACrD,OAAO,CAA0B;IAEjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YAAY,IAAY,EAAE,OAAe,EAAE,UAAmC,EAAE;QAC9E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,CAAC,KAAK,EAAE,QAAQ,IAAI,UAAU,CAAsB,CAAC;QACrE,IAAI,CAAC,SAAS,GAAG,KAAK,EAAE,SAAS,IAAI,KAAK,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,IAAI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AC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -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
|
|
@@ -51,7 +96,17 @@ export declare function healthCheck(config?: HealthCheckConfig): (_req: unknown,
|
|
|
51
96
|
};
|
|
52
97
|
}) => Promise<void>;
|
|
53
98
|
/**
|
|
54
|
-
* Create a
|
|
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}
|
|
55
110
|
*
|
|
56
111
|
* @example
|
|
57
112
|
* ```typescript
|
|
@@ -69,7 +124,18 @@ export declare function createDatabaseHealthCheck(config: {
|
|
|
69
124
|
name?: string;
|
|
70
125
|
}): HealthCheckFunction;
|
|
71
126
|
/**
|
|
72
|
-
* Create an external service
|
|
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}
|
|
73
139
|
*
|
|
74
140
|
* @example
|
|
75
141
|
* ```typescript
|
|
@@ -86,7 +152,14 @@ export declare function createExternalServiceHealthCheck(config: {
|
|
|
86
152
|
timeout?: number;
|
|
87
153
|
}): HealthCheckFunction;
|
|
88
154
|
/**
|
|
89
|
-
* Liveness probe
|
|
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
|
|
90
163
|
*
|
|
91
164
|
* @example
|
|
92
165
|
* ```typescript
|
|
@@ -99,7 +172,15 @@ export declare function livenessProbe(): (_req: unknown, res: {
|
|
|
99
172
|
};
|
|
100
173
|
}) => void;
|
|
101
174
|
/**
|
|
102
|
-
* Readiness probe
|
|
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
|
|
103
184
|
*
|
|
104
185
|
* @example
|
|
105
186
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/health/index.ts"],"names":[],"mappings":"AAAA
|
|
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;IAChC,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IAEb,mCAAmC;IACnC,MAAM,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;IAEnC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,MA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AE1E,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"}
|
package/dist/src/health/index.js
CHANGED
|
@@ -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
|
|
@@ -88,7 +100,17 @@ export function healthCheck(config = {}) {
|
|
|
88
100
|
};
|
|
89
101
|
}
|
|
90
102
|
/**
|
|
91
|
-
* Create a
|
|
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
|
|
@@ -121,7 +143,18 @@ export function createDatabaseHealthCheck(config) {
|
|
|
121
143
|
};
|
|
122
144
|
}
|
|
123
145
|
/**
|
|
124
|
-
* Create an external service
|
|
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
|
|
@@ -160,7 +193,14 @@ export function createExternalServiceHealthCheck(config) {
|
|
|
160
193
|
};
|
|
161
194
|
}
|
|
162
195
|
/**
|
|
163
|
-
* Liveness probe
|
|
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
|
|
@@ -176,7 +216,15 @@ export function livenessProbe() {
|
|
|
176
216
|
};
|
|
177
217
|
}
|
|
178
218
|
/**
|
|
179
|
-
* Readiness probe
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/health/index.ts"],"names":[],"mappings":"AAAA
|
|
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,IA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BACnB,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"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
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
|
+
*/
|
|
1
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';
|
|
2
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';
|
|
3
14
|
export * from './budgetEnforcement.js';
|
|
@@ -13,8 +24,8 @@ export * from './fieldExtraction.js';
|
|
|
13
24
|
export * from './flagResolver.js';
|
|
14
25
|
export * from './flagSemantics.js';
|
|
15
26
|
export * from './health/index.js';
|
|
16
|
-
export * from './mcpAdapter.js';
|
|
17
27
|
export * from './mviProjection.js';
|
|
28
|
+
export { isNativeAvailable } from './native-loader.js';
|
|
18
29
|
export type { LafsProblemDetails } from './problemDetails.js';
|
|
19
30
|
export { lafsErrorToProblemDetails, PROBLEM_DETAILS_CONTENT_TYPE } from './problemDetails.js';
|
|
20
31
|
export * from './shutdown/index.js';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
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,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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
|
+
*/
|
|
1
12
|
// A2A Integration
|
|
2
13
|
// Explicitly re-export to avoid naming conflicts with discovery types
|
|
3
14
|
// (AgentCard, AgentSkill, AgentCapabilities, AgentExtension).
|
|
@@ -25,8 +36,8 @@ export * from './flagResolver.js';
|
|
|
25
36
|
export * from './flagSemantics.js';
|
|
26
37
|
// Operations & Reliability
|
|
27
38
|
export * from './health/index.js';
|
|
28
|
-
export * from './mcpAdapter.js';
|
|
29
39
|
export * from './mviProjection.js';
|
|
40
|
+
export { isNativeAvailable } from './native-loader.js';
|
|
30
41
|
export { lafsErrorToProblemDetails, PROBLEM_DETAILS_CONTENT_TYPE } from './problemDetails.js';
|
|
31
42
|
export * from './shutdown/index.js';
|
|
32
43
|
export * from './tokenEstimator.js';
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
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,20 +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'
|
|
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
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
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
|
-
*
|
|
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;
|
|
20
56
|
//# sourceMappingURL=mviProjection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mviProjection.d.ts","sourceRoot":"","sources":["../../src/mviProjection.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project an envelope to the declared MVI verbosity level.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* @param envelope - The full LAFS envelope to project
|
|
5
|
+
* @param mviLevel - Override MVI level; falls back to `envelope._meta.mvi`, then `'standard'`
|
|
6
|
+
* @returns A plain object containing only the fields appropriate for the resolved MVI level
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* MVI levels control projection behavior:
|
|
10
|
+
* - `'minimal'`: only fields required for agent control flow (success, error code, retry info)
|
|
11
|
+
* - `'standard'`: all commonly useful fields (current default behavior)
|
|
12
|
+
* - `'full'`: complete echo-back including request parameters
|
|
13
|
+
* - `'custom'`: no projection (controlled by field extraction layer)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const minimal = projectEnvelope(envelope, 'minimal');
|
|
18
|
+
* // minimal contains only: success, _meta (requestId, contextVersion), result/error
|
|
19
|
+
* ```
|
|
7
20
|
*/
|
|
8
21
|
export function projectEnvelope(envelope, mviLevel) {
|
|
9
22
|
const level = mviLevel ?? envelope._meta.mvi ?? 'standard';
|
|
@@ -108,7 +121,20 @@ function projectErrorMinimal(error) {
|
|
|
108
121
|
}
|
|
109
122
|
/**
|
|
110
123
|
* Estimate token count for a projected envelope.
|
|
111
|
-
*
|
|
124
|
+
*
|
|
125
|
+
* @param projected - The projected envelope object to estimate
|
|
126
|
+
* @returns The estimated token count based on JSON serialization length
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* Uses a simple heuristic of 1 token per approximately 4 characters of
|
|
130
|
+
* JSON-serialized output. This is an approximation suitable for budget
|
|
131
|
+
* enforcement, not an exact tokenizer count.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const tokens = estimateProjectedTokens(projectEnvelope(envelope, 'minimal'));
|
|
136
|
+
* // tokens ~= Math.ceil(JSON.stringify(projected).length / 4)
|
|
137
|
+
* ```
|
|
112
138
|
*/
|
|
113
139
|
export function estimateProjectedTokens(projected) {
|
|
114
140
|
const json = JSON.stringify(projected);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mviProjection.js","sourceRoot":"","sources":["../../src/mviProjection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mviProjection.js","sourceRoot":"","sources":["../../src/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ED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAkC;IACxE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
/** Shape of a structured validation error from the native binding. */
|
|
13
|
+
interface NativeValidationError {
|
|
14
|
+
/** JSON Pointer path to the failing property. */
|
|
15
|
+
path: string;
|
|
16
|
+
/** JSON Schema keyword that triggered the error. */
|
|
17
|
+
keyword: string;
|
|
18
|
+
/** Human-readable error message. */
|
|
19
|
+
message: string;
|
|
20
|
+
/** Keyword-specific parameters. */
|
|
21
|
+
params: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/** Shape of the validation result from the native binding. */
|
|
24
|
+
export interface NativeValidationResult {
|
|
25
|
+
/** Whether the envelope conforms to the schema. */
|
|
26
|
+
valid: boolean;
|
|
27
|
+
/** Flattened human-readable error messages. */
|
|
28
|
+
errors: string[];
|
|
29
|
+
/** Structured error objects. */
|
|
30
|
+
structuredErrors: NativeValidationError[];
|
|
31
|
+
}
|
|
32
|
+
/** Shape of the native LAFS addon. */
|
|
33
|
+
interface LafsNativeModule {
|
|
34
|
+
lafsValidateEnvelope(payload: string): NativeValidationResult;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if the native addon is available.
|
|
38
|
+
*
|
|
39
|
+
* @returns `true` if the native Rust binding was loaded successfully.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isNativeAvailable(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Get the native module, or `null` if unavailable.
|
|
44
|
+
*
|
|
45
|
+
* @returns The loaded native module, or `null` for AJV fallback.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getNativeModule(): LafsNativeModule | null;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=native-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-loader.d.ts","sourceRoot":"","sources":["../../src/native-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,sEAAsE;AACtE,UAAU,qBAAqB;IAC7B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,8DAA8D;AAC9D,MAAM,WAAW,sBAAsB;IACrC,mDAAmD;IACnD,KAAK,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gCAAgC;IAChC,gBAAgB,EAAE,qBAAqB,EAAE,CAAC;CAC3C;AAED,sCAAsC;AACtC,UAAU,gBAAgB;IACxB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB,CAAC;CAC/D;AA2BD;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAG3C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,GAAG,IAAI,CAGzD"}
|