@pellux/goodvibes-sdk 0.25.1 → 0.25.2

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 (34) hide show
  1. package/dist/_internal/daemon/otlp-protobuf.d.ts +3 -0
  2. package/dist/_internal/daemon/otlp-protobuf.d.ts.map +1 -0
  3. package/dist/_internal/daemon/otlp-protobuf.js +968 -0
  4. package/dist/_internal/daemon/telemetry-routes.d.ts.map +1 -1
  5. package/dist/_internal/daemon/telemetry-routes.js +22 -13
  6. package/dist/_internal/platform/version.js +1 -1
  7. package/package.json +1 -1
  8. package/dist/_internal/platform/runtime/contracts/index.d.ts +0 -40
  9. package/dist/_internal/platform/runtime/contracts/index.d.ts.map +0 -1
  10. package/dist/_internal/platform/runtime/contracts/index.js +0 -133
  11. package/dist/_internal/platform/runtime/contracts/migrations/index.d.ts +0 -75
  12. package/dist/_internal/platform/runtime/contracts/migrations/index.d.ts.map +0 -1
  13. package/dist/_internal/platform/runtime/contracts/migrations/index.js +0 -158
  14. package/dist/_internal/platform/runtime/contracts/migrations/schemas.d.ts +0 -57
  15. package/dist/_internal/platform/runtime/contracts/migrations/schemas.d.ts.map +0 -1
  16. package/dist/_internal/platform/runtime/contracts/migrations/schemas.js +0 -157
  17. package/dist/_internal/platform/runtime/contracts/types.d.ts +0 -123
  18. package/dist/_internal/platform/runtime/contracts/types.d.ts.map +0 -1
  19. package/dist/_internal/platform/runtime/contracts/types.js +0 -41
  20. package/dist/_internal/platform/runtime/contracts/validators/event-envelope.d.ts +0 -24
  21. package/dist/_internal/platform/runtime/contracts/validators/event-envelope.d.ts.map +0 -1
  22. package/dist/_internal/platform/runtime/contracts/validators/event-envelope.js +0 -104
  23. package/dist/_internal/platform/runtime/contracts/validators/index.d.ts +0 -11
  24. package/dist/_internal/platform/runtime/contracts/validators/index.d.ts.map +0 -1
  25. package/dist/_internal/platform/runtime/contracts/validators/index.js +0 -10
  26. package/dist/_internal/platform/runtime/contracts/validators/runtime-state.d.ts +0 -23
  27. package/dist/_internal/platform/runtime/contracts/validators/runtime-state.d.ts.map +0 -1
  28. package/dist/_internal/platform/runtime/contracts/validators/runtime-state.js +0 -101
  29. package/dist/_internal/platform/runtime/contracts/validators/session.d.ts +0 -24
  30. package/dist/_internal/platform/runtime/contracts/validators/session.d.ts.map +0 -1
  31. package/dist/_internal/platform/runtime/contracts/validators/session.js +0 -103
  32. package/dist/_internal/platform/runtime/contracts/version.d.ts +0 -84
  33. package/dist/_internal/platform/runtime/contracts/version.d.ts.map +0 -1
  34. package/dist/_internal/platform/runtime/contracts/version.js +0 -41
@@ -1,157 +0,0 @@
1
- /**
2
- * Compatibility Contracts — Consolidated Migration Schemas
3
- *
4
- * All domain migration steps in one place. Each schema section:
5
- * - Declares a private `_STEPS` array (MigrationStep[])
6
- * - Exports a `_VERSION` constant (re-exported from SCHEMA_VERSIONS)
7
- * - Exports a `get…MigrationSteps()` function for the contract registry
8
- *
9
- * Previously split across 5 stub files; consolidated here for DRY.
10
- * Split back out if any individual contract accumulates > 10 migration steps.
11
- *
12
- * All migration functions must be pure — no mutations, no side effects.
13
- *
14
- * @module contracts/migrations/schemas
15
- */
16
- import { SCHEMA_VERSIONS } from '../version.js';
17
- // ─── EventEnvelope ────────────────────────────────────────────────────────────
18
- /**
19
- * All registered EventEnvelope migration steps.
20
- *
21
- * Currently empty — the schema is at its initial version (1.0.0).
22
- * Future steps must be appended here and registered via the contract registry.
23
- *
24
- * Example: if `agentId` becomes required in v1.1.0, a migration step would
25
- * backfill it with a sentinel value for older persisted envelopes.
26
- */
27
- const EVENT_ENVELOPE_STEPS = [
28
- // Example structure for future use:
29
- // {
30
- // from: { major: 1, minor: 0, patch: 0 },
31
- // to: { major: 1, minor: 1, patch: 0 },
32
- // description: 'Backfill missing agentId with null sentinel',
33
- // migrate: (data: unknown): unknown => {
34
- // const d = data as Record<string, unknown>;
35
- // return { ...d, agentId: d['agentId'] ?? null };
36
- // },
37
- // },
38
- ];
39
- /** The current EventEnvelope schema version (re-exported for convenience). */
40
- export const EVENT_ENVELOPE_VERSION = SCHEMA_VERSIONS.eventEnvelope;
41
- /** Returns all EventEnvelope migration steps. Used by the contract registry. */
42
- export function getEventEnvelopeMigrationSteps() {
43
- return EVENT_ENVELOPE_STEPS;
44
- }
45
- // ─── PluginManifest ───────────────────────────────────────────────────────────
46
- /**
47
- * All registered PluginManifest migration steps.
48
- *
49
- * Currently empty — the schema is at its initial version (1.0.0).
50
- * Future steps must be appended here and registered via the contract registry.
51
- *
52
- * Example: if `capabilities` becomes an explicit array in v1.1.0, a migration
53
- * step would synthesize it from `registerCommand`/`registerTool` declarations.
54
- */
55
- const PLUGIN_MANIFEST_STEPS = [
56
- // Example structure for future use:
57
- // {
58
- // from: { major: 1, minor: 0, patch: 0 },
59
- // to: { major: 1, minor: 1, patch: 0 },
60
- // description: 'Add capabilities array to plugin manifest',
61
- // migrate: (data: unknown): unknown => {
62
- // const d = data as Record<string, unknown>;
63
- // return { ...d, capabilities: d['capabilities'] ?? [] };
64
- // },
65
- // },
66
- ];
67
- /** The current PluginManifest schema version (re-exported for convenience). */
68
- export const PLUGIN_MANIFEST_VERSION = SCHEMA_VERSIONS.pluginManifest;
69
- /** Returns all PluginManifest migration steps. Used by the contract registry. */
70
- export function getPluginManifestMigrationSteps() {
71
- return PLUGIN_MANIFEST_STEPS;
72
- }
73
- // ─── RuntimeState ─────────────────────────────────────────────────────────────
74
- /**
75
- * All registered RuntimeState migration steps.
76
- *
77
- * Currently empty — the schema is at its initial version (1.0.0).
78
- * Future steps must be appended here and registered via the contract registry.
79
- *
80
- * Example: if `uiSettings` is added in v1.1.0, a step would backfill it with
81
- * default values for existing persisted snapshots.
82
- */
83
- const RUNTIME_STATE_STEPS = [
84
- // Example structure for future use:
85
- // {
86
- // from: { major: 1, minor: 0, patch: 0 },
87
- // to: { major: 1, minor: 1, patch: 0 },
88
- // description: 'Add optional uiSettings field with defaults',
89
- // migrate: (data: unknown): unknown => {
90
- // const d = data as Record<string, unknown>;
91
- // return { ...d, uiSettings: d['uiSettings'] ?? { theme: 'dark' } };
92
- // },
93
- // },
94
- ];
95
- /** The current RuntimeState schema version (re-exported for convenience). */
96
- export const RUNTIME_STATE_VERSION = SCHEMA_VERSIONS.runtimeState;
97
- /** Returns all RuntimeState migration steps. Used by the contract registry. */
98
- export function getRuntimeStateMigrationSteps() {
99
- return RUNTIME_STATE_STEPS;
100
- }
101
- // ─── Session ──────────────────────────────────────────────────────────────────
102
- /**
103
- * All registered Session migration steps.
104
- *
105
- * Currently empty — the schema is at its initial version (1.0.0).
106
- * Future steps must be appended here and registered via the contract registry.
107
- *
108
- * Example: if session files gain a `tags` array in v1.1.0, a migration step
109
- * would backfill it as an empty array for existing sessions.
110
- */
111
- const SESSION_STEPS = [
112
- // Example structure for future use:
113
- // {
114
- // from: { major: 1, minor: 0, patch: 0 },
115
- // to: { major: 1, minor: 1, patch: 0 },
116
- // description: 'Add empty tags array to session meta',
117
- // migrate: (data: unknown): unknown => {
118
- // const d = data as Record<string, unknown>;
119
- // const meta = d['meta'] as Record<string, unknown>;
120
- // return { ...d, meta: { ...meta, tags: meta['tags'] ?? [] } };
121
- // },
122
- // },
123
- ];
124
- /** The current Session schema version (re-exported for convenience). */
125
- export const SESSION_VERSION = SCHEMA_VERSIONS.session;
126
- /** Returns all Session migration steps. Used by the contract registry. */
127
- export function getSessionMigrationSteps() {
128
- return SESSION_STEPS;
129
- }
130
- // ─── TaskRecord ───────────────────────────────────────────────────────────────
131
- /**
132
- * All registered TaskRecord migration steps.
133
- *
134
- * Currently empty — the schema is at its initial version (1.0.0).
135
- * Future steps must be appended here and registered via the contract registry.
136
- *
137
- * Example: if `metadata` map is added to RuntimeTask in v1.1.0, a migration
138
- * step would backfill it as an empty object for existing persisted records.
139
- */
140
- const TASK_RECORD_STEPS = [
141
- // Example structure for future use:
142
- // {
143
- // from: { major: 1, minor: 0, patch: 0 },
144
- // to: { major: 1, minor: 1, patch: 0 },
145
- // description: 'Add metadata object to task records',
146
- // migrate: (data: unknown): unknown => {
147
- // const d = data as Record<string, unknown>;
148
- // return { ...d, metadata: d['metadata'] ?? {} };
149
- // },
150
- // },
151
- ];
152
- /** The current TaskRecord schema version (re-exported for convenience). */
153
- export const TASK_RECORD_VERSION = SCHEMA_VERSIONS.taskRecord;
154
- /** Returns all TaskRecord migration steps. Used by the contract registry. */
155
- export function getTaskRecordMigrationSteps() {
156
- return TASK_RECORD_STEPS;
157
- }
@@ -1,123 +0,0 @@
1
- /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
- /**
3
- * Compatibility Contracts — Core Types
4
- *
5
- * Defines the foundational types used by the schema versioning and migration
6
- * infrastructure across all runtime domains.
7
- *
8
- * @module contracts/types
9
- */
10
- /**
11
- * A semantic version identifier for a schema.
12
- *
13
- * Follows major.minor.patch semantics:
14
- * - major: breaking change, requires explicit migration
15
- * - minor: additive change, backward-compatible
16
- * - patch: non-structural fix, always backward-compatible
17
- */
18
- export interface SchemaVersion {
19
- readonly major: number;
20
- readonly minor: number;
21
- readonly patch: number;
22
- }
23
- /**
24
- * The result of a schema validation operation.
25
- */
26
- export interface ValidationResult {
27
- /** Whether the data is valid against the expected schema. */
28
- readonly valid: boolean;
29
- /** Structured list of validation errors (empty when valid). */
30
- readonly errors: ValidationError[];
31
- /** The detected schema version, if parseable. */
32
- readonly version?: SchemaVersion;
33
- }
34
- /**
35
- * A single validation failure with path and diagnostic context.
36
- */
37
- export interface ValidationError {
38
- /** Dot-delimited path to the invalid field (e.g. 'envelope.sessionId'). */
39
- readonly path: string;
40
- /** Human-readable description of the failure. */
41
- readonly message: string;
42
- /** Description of the expected type or value. */
43
- readonly expected?: string;
44
- /** Description of the actual type or value found. */
45
- readonly actual?: string;
46
- }
47
- /**
48
- * A pure transformation function that migrates data from one schema version
49
- * to the next. Must not mutate the input — return a new object.
50
- *
51
- * The `unknown` input/output types are intentional: migration functions operate
52
- * on raw persisted data whose shape may predate current TypeScript interfaces.
53
- */
54
- export type MigrationFn = (data: unknown) => unknown;
55
- /**
56
- * Describes a single step in a migration chain, moving data from `from` to `to`.
57
- *
58
- * All steps must be registered in the MigrationRegistry before use.
59
- */
60
- export interface MigrationStep {
61
- /** Source schema version this step migrates from. */
62
- readonly from: SchemaVersion;
63
- /** Target schema version this step migrates to. */
64
- readonly to: SchemaVersion;
65
- /** Pure transformation function. Must not mutate input. */
66
- readonly migrate: MigrationFn;
67
- /** Human-readable description of what this migration changes. */
68
- readonly description: string;
69
- }
70
- /**
71
- * The result of a migration operation, containing the transformed data
72
- * and the version it was migrated to.
73
- */
74
- export interface MigrationResult {
75
- /** The migrated data at the target schema version. */
76
- readonly data: unknown;
77
- /** The schema version of the migrated data. */
78
- readonly version: SchemaVersion;
79
- }
80
- /**
81
- * A schema contract defines the versioning, validation, and migration
82
- * interface for a single domain schema (e.g. RuntimeState, EventEnvelope).
83
- */
84
- export interface SchemaContract {
85
- /** Unique name identifying this contract (e.g. 'runtimeState'). */
86
- readonly name: string;
87
- /** The current schema version emitted by this runtime. */
88
- readonly currentVersion: SchemaVersion;
89
- /** The oldest schema version this runtime can still migrate from. */
90
- readonly minSupportedVersion: SchemaVersion;
91
- /**
92
- * Validates that the given data matches the expected schema shape.
93
- * Performs runtime type checks — not just TypeScript type narrowing.
94
- */
95
- validate: (data: unknown) => ValidationResult;
96
- /**
97
- * Migrates data from an older schema version to the current version.
98
- * Returns a MigrationResult with the migrated data and target version,
99
- * or throws if migration is not possible.
100
- */
101
- migrate: (data: unknown, fromVersion: SchemaVersion) => MigrationResult;
102
- }
103
- /**
104
- * Compares two SchemaVersions. Returns:
105
- * - negative if a < b
106
- * - 0 if a === b
107
- * - positive if a > b
108
- */
109
- export declare function compareVersions(a: SchemaVersion, b: SchemaVersion): number;
110
- /**
111
- * Returns true if the two SchemaVersions are equal.
112
- */
113
- export declare function versionsEqual(a: SchemaVersion, b: SchemaVersion): boolean;
114
- /**
115
- * Serializes a SchemaVersion to a canonical string (e.g. '1.0.0').
116
- */
117
- export declare function versionToString(v: SchemaVersion): string;
118
- /**
119
- * Parses a version string (e.g. '1.2.3') into a SchemaVersion.
120
- * Throws if the string is not a valid semver triple.
121
- */
122
- export declare function parseVersion(raw: string): SchemaVersion;
123
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/contracts/types.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;GAOG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IACnC,iDAAiD;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC;IACvC,qEAAqE;IACrE,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC;IAC5C;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,gBAAgB,CAAC;IAC9C;;;;OAIG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,KAAK,eAAe,CAAC;CACzE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,MAAM,CAI1E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAEzE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAUvD"}
@@ -1,41 +0,0 @@
1
- /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
- /**
3
- * Compares two SchemaVersions. Returns:
4
- * - negative if a < b
5
- * - 0 if a === b
6
- * - positive if a > b
7
- */
8
- export function compareVersions(a, b) {
9
- if (a.major !== b.major)
10
- return a.major - b.major;
11
- if (a.minor !== b.minor)
12
- return a.minor - b.minor;
13
- return a.patch - b.patch;
14
- }
15
- /**
16
- * Returns true if the two SchemaVersions are equal.
17
- */
18
- export function versionsEqual(a, b) {
19
- return a.major === b.major && a.minor === b.minor && a.patch === b.patch;
20
- }
21
- /**
22
- * Serializes a SchemaVersion to a canonical string (e.g. '1.0.0').
23
- */
24
- export function versionToString(v) {
25
- return `${v.major}.${v.minor}.${v.patch}`;
26
- }
27
- /**
28
- * Parses a version string (e.g. '1.2.3') into a SchemaVersion.
29
- * Throws if the string is not a valid semver triple.
30
- */
31
- export function parseVersion(raw) {
32
- const parts = raw.split('.');
33
- if (parts.length !== 3) {
34
- throw new Error(`Invalid schema version string: '${raw}' (expected 'major.minor.patch')`);
35
- }
36
- const [major, minor, patch] = parts.map(Number);
37
- if (!Number.isInteger(major) || !Number.isInteger(minor) || !Number.isInteger(patch)) {
38
- throw new Error(`Non-integer component in schema version: '${raw}'`);
39
- }
40
- return { major, minor, patch };
41
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Compatibility Contracts — EventEnvelope Validator
3
- *
4
- * Performs runtime shape validation for the RuntimeEventEnvelope persistence schema.
5
- * Returns a structured ValidationResult rather than throwing.
6
- *
7
- * @module contracts/validators/event-envelope
8
- */
9
- import type { ValidationResult } from '../types.js';
10
- /**
11
- * Validates that `data` conforms to the expected RuntimeEventEnvelope persistence shape.
12
- *
13
- * Checks:
14
- * - `data` is a non-null object
15
- * - `type`, `traceId`, `sessionId`, `source` are non-empty strings
16
- * - `ts` is a finite number (Unix ms timestamp)
17
- * - `payload` is present and is a non-null object
18
- * - `version` (if present) has numeric `major`, `minor`, `patch` fields
19
- *
20
- * @param data - The raw persisted data to validate.
21
- * @returns A ValidationResult with structured errors if any field is invalid.
22
- */
23
- export declare function validateEventEnvelope(data: unknown): ValidationResult;
24
- //# sourceMappingURL=event-envelope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-envelope.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/runtime/contracts/validators/event-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAkC,MAAM,aAAa,CAAC;AAOpF;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAgFrE"}
@@ -1,104 +0,0 @@
1
- /**
2
- * Compatibility Contracts — EventEnvelope Validator
3
- *
4
- * Performs runtime shape validation for the RuntimeEventEnvelope persistence schema.
5
- * Returns a structured ValidationResult rather than throwing.
6
- *
7
- * @module contracts/validators/event-envelope
8
- */
9
- /**
10
- * Required fields for a persisted RuntimeEventEnvelope.
11
- */
12
- const REQUIRED_STRING_FIELDS = ['type', 'traceId', 'sessionId', 'source'];
13
- /**
14
- * Validates that `data` conforms to the expected RuntimeEventEnvelope persistence shape.
15
- *
16
- * Checks:
17
- * - `data` is a non-null object
18
- * - `type`, `traceId`, `sessionId`, `source` are non-empty strings
19
- * - `ts` is a finite number (Unix ms timestamp)
20
- * - `payload` is present and is a non-null object
21
- * - `version` (if present) has numeric `major`, `minor`, `patch` fields
22
- *
23
- * @param data - The raw persisted data to validate.
24
- * @returns A ValidationResult with structured errors if any field is invalid.
25
- */
26
- export function validateEventEnvelope(data) {
27
- const errors = [];
28
- if (data === null || typeof data !== 'object') {
29
- errors.push({
30
- path: '',
31
- message: 'EventEnvelope must be a non-null object',
32
- expected: 'object',
33
- actual: data === null ? 'null' : typeof data,
34
- });
35
- return { valid: false, errors };
36
- }
37
- const record = data;
38
- // Validate required string fields
39
- for (const field of REQUIRED_STRING_FIELDS) {
40
- const value = record[field];
41
- if (typeof value !== 'string' || value.length === 0) {
42
- errors.push({
43
- path: field,
44
- message: `Field '${field}' must be a non-empty string`,
45
- expected: 'non-empty string',
46
- actual: value === undefined ? 'undefined' : value === null ? 'null' : typeof value,
47
- });
48
- }
49
- }
50
- // Validate ts: finite number
51
- const tsRaw = record['ts'];
52
- if (typeof tsRaw !== 'number' || !Number.isFinite(tsRaw)) {
53
- errors.push({
54
- path: 'ts',
55
- message: "Field 'ts' must be a finite number (Unix ms timestamp)",
56
- expected: 'finite number',
57
- actual: tsRaw === undefined ? 'undefined' : tsRaw === null ? 'null' : typeof tsRaw,
58
- });
59
- }
60
- // Validate payload: non-null object
61
- const payloadRaw = record['payload'];
62
- if (payloadRaw === undefined || payloadRaw === null || typeof payloadRaw !== 'object') {
63
- errors.push({
64
- path: 'payload',
65
- message: "Field 'payload' must be a non-null object",
66
- expected: 'object',
67
- actual: payloadRaw === undefined ? 'undefined' : payloadRaw === null ? 'null' : typeof payloadRaw,
68
- });
69
- }
70
- // Detect version if present
71
- let detectedVersion;
72
- const versionRaw = record['version'];
73
- if (versionRaw !== undefined && versionRaw !== null && typeof versionRaw === 'object') {
74
- const v = versionRaw;
75
- const allNumeric = typeof v['major'] === 'number' &&
76
- typeof v['minor'] === 'number' &&
77
- typeof v['patch'] === 'number';
78
- if (allNumeric) {
79
- detectedVersion = {
80
- major: v['major'],
81
- minor: v['minor'],
82
- patch: v['patch'],
83
- };
84
- }
85
- else {
86
- errors.push({
87
- path: 'version',
88
- message: "Field 'version' must have numeric major, minor, patch components",
89
- expected: '{ major: number, minor: number, patch: number }',
90
- actual: (() => { try {
91
- return JSON.stringify(versionRaw);
92
- }
93
- catch {
94
- return String(versionRaw);
95
- } })(),
96
- });
97
- }
98
- }
99
- return {
100
- valid: errors.length === 0,
101
- errors,
102
- version: detectedVersion,
103
- };
104
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Compatibility Contracts — Validators barrel
3
- *
4
- * Re-exports all runtime shape validators for the contract registry.
5
- *
6
- * @module contracts/validators
7
- */
8
- export { validateRuntimeState } from './runtime-state.js';
9
- export { validateEventEnvelope } from './event-envelope.js';
10
- export { validateSession } from './session.js';
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/runtime/contracts/validators/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Compatibility Contracts — Validators barrel
3
- *
4
- * Re-exports all runtime shape validators for the contract registry.
5
- *
6
- * @module contracts/validators
7
- */
8
- export { validateRuntimeState } from './runtime-state.js';
9
- export { validateEventEnvelope } from './event-envelope.js';
10
- export { validateSession } from './session.js';
@@ -1,23 +0,0 @@
1
- /**
2
- * Compatibility Contracts — RuntimeState Validator
3
- *
4
- * Performs runtime shape validation for the top-level RuntimeState snapshot schema.
5
- * Returns a structured ValidationResult rather than throwing.
6
- *
7
- * @module contracts/validators/runtime-state
8
- */
9
- import type { ValidationResult } from '../types.js';
10
- /**
11
- * Validates that `data` conforms to the expected RuntimeState snapshot shape.
12
- *
13
- * Checks:
14
- * - `data` is a non-null object
15
- * - `version` is present and has numeric `major`, `minor`, `patch` fields
16
- * - `domains` is present and is a non-null object
17
- *
18
- * @param data - The raw persisted data to validate.
19
- * @returns A ValidationResult with `valid: true` if the shape is correct,
20
- * or `valid: false` with a list of errors if any required field is missing or malformed.
21
- */
22
- export declare function validateRuntimeState(data: unknown): ValidationResult;
23
- //# sourceMappingURL=runtime-state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-state.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/runtime/contracts/validators/runtime-state.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAkC,MAAM,aAAa,CAAC;AAQpF;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAgFpE"}
@@ -1,101 +0,0 @@
1
- /**
2
- * Compatibility Contracts — RuntimeState Validator
3
- *
4
- * Performs runtime shape validation for the top-level RuntimeState snapshot schema.
5
- * Returns a structured ValidationResult rather than throwing.
6
- *
7
- * @module contracts/validators/runtime-state
8
- */
9
- /**
10
- * Expected top-level field names for a RuntimeState snapshot.
11
- * Validated as required string/object fields at the top level.
12
- */
13
- const REQUIRED_FIELDS = ['version', 'domains'];
14
- /**
15
- * Validates that `data` conforms to the expected RuntimeState snapshot shape.
16
- *
17
- * Checks:
18
- * - `data` is a non-null object
19
- * - `version` is present and has numeric `major`, `minor`, `patch` fields
20
- * - `domains` is present and is a non-null object
21
- *
22
- * @param data - The raw persisted data to validate.
23
- * @returns A ValidationResult with `valid: true` if the shape is correct,
24
- * or `valid: false` with a list of errors if any required field is missing or malformed.
25
- */
26
- export function validateRuntimeState(data) {
27
- const errors = [];
28
- if (data === null || typeof data !== 'object') {
29
- errors.push({
30
- path: '',
31
- message: 'RuntimeState must be a non-null object',
32
- expected: 'object',
33
- actual: data === null ? 'null' : typeof data,
34
- });
35
- return { valid: false, errors };
36
- }
37
- const record = data;
38
- // Check all required top-level fields are present
39
- for (const field of REQUIRED_FIELDS) {
40
- if (!(field in record)) {
41
- errors.push({
42
- path: field,
43
- message: `Missing required field '${field}'`,
44
- expected: 'present',
45
- actual: 'undefined',
46
- });
47
- }
48
- }
49
- // Validate version shape: { major: number, minor: number, patch: number }
50
- let detectedVersion;
51
- const versionRaw = record['version'];
52
- if (versionRaw !== undefined) {
53
- if (versionRaw === null || typeof versionRaw !== 'object') {
54
- errors.push({
55
- path: 'version',
56
- message: 'Field \'version\' must be a non-null object',
57
- expected: '{ major: number, minor: number, patch: number }',
58
- actual: versionRaw === null ? 'null' : typeof versionRaw,
59
- });
60
- }
61
- else {
62
- const v = versionRaw;
63
- const vErrors = [];
64
- for (const component of ['major', 'minor', 'patch']) {
65
- if (typeof v[component] !== 'number') {
66
- vErrors.push({
67
- path: `version.${component}`,
68
- message: `Field 'version.${component}' must be a number`,
69
- expected: 'number',
70
- actual: v[component] === null ? 'null' : typeof v[component],
71
- });
72
- }
73
- }
74
- errors.push(...vErrors);
75
- if (vErrors.length === 0) {
76
- detectedVersion = {
77
- major: v['major'],
78
- minor: v['minor'],
79
- patch: v['patch'],
80
- };
81
- }
82
- }
83
- }
84
- // Validate domains is a non-null object
85
- const domainsRaw = record['domains'];
86
- if (domainsRaw !== undefined) {
87
- if (domainsRaw === null || typeof domainsRaw !== 'object' || Array.isArray(domainsRaw)) {
88
- errors.push({
89
- path: 'domains',
90
- message: "Field 'domains' must be a non-null, non-array object",
91
- expected: 'object',
92
- actual: domainsRaw === null ? 'null' : Array.isArray(domainsRaw) ? 'array' : typeof domainsRaw,
93
- });
94
- }
95
- }
96
- return {
97
- valid: errors.length === 0,
98
- errors,
99
- version: detectedVersion,
100
- };
101
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Compatibility Contracts — Session Validator
3
- *
4
- * Performs runtime shape validation for the session persistence format
5
- * (messages array + meta object). Returns a structured ValidationResult.
6
- *
7
- * @module contracts/validators/session
8
- */
9
- import type { ValidationResult } from '../types.js';
10
- /**
11
- * Validates that `data` conforms to the expected session persistence shape.
12
- *
13
- * Checks:
14
- * - `data` is a non-null object
15
- * - `sessionId` is a non-empty string
16
- * - `messages` is an array (contents are not deeply validated)
17
- * - `meta` is a non-null, non-array object
18
- * - `meta.version` (if present) has numeric `major`, `minor`, `patch` fields
19
- *
20
- * @param data - The raw persisted data to validate.
21
- * @returns A ValidationResult with structured errors if any field is invalid.
22
- */
23
- export declare function validateSession(data: unknown): ValidationResult;
24
- //# sourceMappingURL=session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/runtime/contracts/validators/session.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAkC,MAAM,aAAa,CAAC;AAEpF;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAmF/D"}