@xerg/schemas 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +5 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Xerg
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @xerg/schemas
|
|
2
|
+
|
|
3
|
+
Versioned TypeScript wire types for Xerg audit payloads, findings, comparisons, and recommendations.
|
|
4
|
+
|
|
5
|
+
## What it is
|
|
6
|
+
|
|
7
|
+
`@xerg/schemas` defines the JSON contract shared between the Xerg CLI, the local audit engine, and any service that consumes pushed audit summaries.
|
|
8
|
+
|
|
9
|
+
It is intentionally small and stable:
|
|
10
|
+
|
|
11
|
+
- TypeScript-first types for Xerg wire payloads
|
|
12
|
+
- A runtime `AUDIT_PUSH_PAYLOAD_VERSION` constant for compatibility checks
|
|
13
|
+
- A dependency-light package surface for backends, ingestion services, and internal tooling
|
|
14
|
+
|
|
15
|
+
## What it is not
|
|
16
|
+
|
|
17
|
+
This package does not perform runtime validation by itself. It provides compile-time guarantees for TypeScript consumers. If you accept untrusted JSON, add runtime validation in the consuming service and keep it aligned with these exported types.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @xerg/schemas
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import {
|
|
29
|
+
AUDIT_PUSH_PAYLOAD_VERSION,
|
|
30
|
+
type AuditPushPayload,
|
|
31
|
+
} from '@xerg/schemas';
|
|
32
|
+
|
|
33
|
+
export function acceptAuditPayload(payload: AuditPushPayload) {
|
|
34
|
+
if (payload.version !== AUDIT_PUSH_PAYLOAD_VERSION) {
|
|
35
|
+
throw new Error(`Unsupported payload version: ${payload.version}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return payload.summary.auditId;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Compatibility contract
|
|
43
|
+
|
|
44
|
+
`AuditPushPayload.version` is the top-level wire version.
|
|
45
|
+
|
|
46
|
+
- Additive fields that older consumers can safely ignore should usually keep the same version.
|
|
47
|
+
- Breaking changes to existing field names, meanings, or required structure should ship behind a new payload version.
|
|
48
|
+
- Producers and consumers should reject payloads with a newer unsupported version instead of guessing.
|
|
49
|
+
|
|
50
|
+
Current version:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { AUDIT_PUSH_PAYLOAD_VERSION } from '@xerg/schemas';
|
|
54
|
+
|
|
55
|
+
AUDIT_PUSH_PAYLOAD_VERSION; // 1
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Exports
|
|
59
|
+
|
|
60
|
+
Primary exports include:
|
|
61
|
+
|
|
62
|
+
- `AuditPushPayload`
|
|
63
|
+
- `WireFinding`
|
|
64
|
+
- `WireComparison`
|
|
65
|
+
- `XergRecommendation`
|
|
66
|
+
- `AUDIT_PUSH_PAYLOAD_VERSION`
|
|
67
|
+
|
|
68
|
+
## Use cases
|
|
69
|
+
|
|
70
|
+
- Share a single payload contract between the Xerg CLI and backend services
|
|
71
|
+
- Type audit ingestion pipelines without copying interface definitions
|
|
72
|
+
- Gate processing logic on an explicit payload version
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
interface WireComparison {
|
|
2
|
+
baselineAuditId: string;
|
|
3
|
+
baselineGeneratedAt: string;
|
|
4
|
+
baselineTotalSpendUsd: number;
|
|
5
|
+
baselineWasteSpendUsd: number;
|
|
6
|
+
baselineStructuralWasteRate: number;
|
|
7
|
+
deltaTotalSpendUsd: number;
|
|
8
|
+
deltaWasteSpendUsd: number;
|
|
9
|
+
deltaStructuralWasteRate: number;
|
|
10
|
+
deltaRunCount: number;
|
|
11
|
+
deltaCallCount: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type WireFindingScope = 'global' | 'workflow' | 'run';
|
|
15
|
+
interface WireFinding {
|
|
16
|
+
id: string;
|
|
17
|
+
classification: 'waste' | 'opportunity';
|
|
18
|
+
confidence: 'high' | 'medium' | 'low';
|
|
19
|
+
kind: string;
|
|
20
|
+
title: string;
|
|
21
|
+
summary: string;
|
|
22
|
+
scope: WireFindingScope;
|
|
23
|
+
scopeId: string;
|
|
24
|
+
costImpactUsd: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare const AUDIT_PUSH_PAYLOAD_VERSION: 1;
|
|
28
|
+
type AuditPushPayloadVersion = typeof AUDIT_PUSH_PAYLOAD_VERSION;
|
|
29
|
+
type PushEnvironment = 'local' | 'remote' | 'railway';
|
|
30
|
+
interface FindingTaxonomyBucket {
|
|
31
|
+
kind: string;
|
|
32
|
+
label: string;
|
|
33
|
+
classification: 'waste' | 'opportunity';
|
|
34
|
+
spendUsd: number;
|
|
35
|
+
findingCount: number;
|
|
36
|
+
}
|
|
37
|
+
interface SpendBreakdown {
|
|
38
|
+
key: string;
|
|
39
|
+
spendUsd: number;
|
|
40
|
+
callCount: number;
|
|
41
|
+
observedShare: number;
|
|
42
|
+
}
|
|
43
|
+
interface AuditPushPayload {
|
|
44
|
+
version: AuditPushPayloadVersion;
|
|
45
|
+
summary: {
|
|
46
|
+
auditId: string;
|
|
47
|
+
generatedAt: string;
|
|
48
|
+
comparisonKey: string;
|
|
49
|
+
runCount: number;
|
|
50
|
+
callCount: number;
|
|
51
|
+
totalSpendUsd: number;
|
|
52
|
+
observedSpendUsd: number;
|
|
53
|
+
estimatedSpendUsd: number;
|
|
54
|
+
wasteSpendUsd: number;
|
|
55
|
+
opportunitySpendUsd: number;
|
|
56
|
+
structuralWasteRate: number;
|
|
57
|
+
wasteByKind: FindingTaxonomyBucket[];
|
|
58
|
+
opportunityByKind: FindingTaxonomyBucket[];
|
|
59
|
+
spendByWorkflow: SpendBreakdown[];
|
|
60
|
+
spendByModel: SpendBreakdown[];
|
|
61
|
+
findings: WireFinding[];
|
|
62
|
+
notes: string[];
|
|
63
|
+
comparison?: WireComparison | null;
|
|
64
|
+
};
|
|
65
|
+
meta: {
|
|
66
|
+
cliVersion: string;
|
|
67
|
+
sourceId: string;
|
|
68
|
+
sourceHost: string;
|
|
69
|
+
environment: PushEnvironment;
|
|
70
|
+
pushedAt: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface XergRecommendation {
|
|
75
|
+
id: string;
|
|
76
|
+
findingId: string;
|
|
77
|
+
kind: string;
|
|
78
|
+
title: string;
|
|
79
|
+
description: string;
|
|
80
|
+
estimatedSavingsUsd: number;
|
|
81
|
+
confidence: 'high' | 'medium' | 'low';
|
|
82
|
+
actionType: 'model-switch' | 'cache-config' | 'prompt-trim' | 'dedup' | 'other';
|
|
83
|
+
suggestedChange?: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { AUDIT_PUSH_PAYLOAD_VERSION, type AuditPushPayload, type AuditPushPayloadVersion, type FindingTaxonomyBucket, type PushEnvironment, type SpendBreakdown, type WireComparison, type WireFinding, type WireFindingScope, type XergRecommendation };
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xerg/schemas",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Versioned TypeScript wire types for Xerg audit payloads, findings, comparisons, and recommendations.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"xerg",
|
|
7
|
+
"schemas",
|
|
8
|
+
"typescript",
|
|
9
|
+
"types",
|
|
10
|
+
"wire-types",
|
|
11
|
+
"api",
|
|
12
|
+
"contracts",
|
|
13
|
+
"audit",
|
|
14
|
+
"openclaw",
|
|
15
|
+
"finops",
|
|
16
|
+
"llm"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://xerg.ai",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"email": "query@xerg.ai",
|
|
21
|
+
"url": "https://xerg.ai"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/xergai/xerg.git",
|
|
26
|
+
"directory": "packages/schemas"
|
|
27
|
+
},
|
|
28
|
+
"author": "Xerg <query@xerg.ai>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"type": "module",
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
46
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {}
|
|
49
|
+
}
|