@pellux/goodvibes-sdk 0.25.1 → 0.25.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/dist/_internal/daemon/otlp-protobuf.d.ts +3 -0
- package/dist/_internal/daemon/otlp-protobuf.d.ts.map +1 -0
- package/dist/_internal/daemon/otlp-protobuf.js +968 -0
- package/dist/_internal/daemon/telemetry-routes.d.ts.map +1 -1
- package/dist/_internal/daemon/telemetry-routes.js +22 -13
- package/dist/_internal/platform/adapters/ntfy/index.d.ts.map +1 -1
- package/dist/_internal/platform/adapters/ntfy/index.js +93 -0
- package/dist/_internal/platform/adapters/types.d.ts +21 -0
- package/dist/_internal/platform/adapters/types.d.ts.map +1 -1
- package/dist/_internal/platform/channels/builtin/setup-schema.d.ts.map +1 -1
- package/dist/_internal/platform/channels/builtin/setup-schema.js +4 -3
- package/dist/_internal/platform/channels/delivery/strategies-core.d.ts.map +1 -1
- package/dist/_internal/platform/channels/delivery/strategies-core.js +1 -0
- package/dist/_internal/platform/channels/provider-runtime.d.ts +1 -1
- package/dist/_internal/platform/channels/provider-runtime.d.ts.map +1 -1
- package/dist/_internal/platform/channels/provider-runtime.js +14 -9
- package/dist/_internal/platform/channels/reply-pipeline.d.ts +1 -0
- package/dist/_internal/platform/channels/reply-pipeline.d.ts.map +1 -1
- package/dist/_internal/platform/channels/reply-pipeline.js +32 -1
- package/dist/_internal/platform/companion/companion-chat-manager.d.ts +12 -0
- package/dist/_internal/platform/companion/companion-chat-manager.d.ts.map +1 -1
- package/dist/_internal/platform/companion/companion-chat-manager.js +41 -0
- package/dist/_internal/platform/config/schema-domain-surfaces.js +1 -1
- package/dist/_internal/platform/control-plane/conversation-message.d.ts +1 -1
- package/dist/_internal/platform/control-plane/conversation-message.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/facade-composition.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/facade-composition.js +3 -0
- package/dist/_internal/platform/daemon/surface-actions.d.ts +21 -1
- package/dist/_internal/platform/daemon/surface-actions.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/surface-actions.js +184 -0
- package/dist/_internal/platform/daemon/surface-delivery.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/surface-delivery.js +2 -0
- package/dist/_internal/platform/integrations/index.d.ts +1 -1
- package/dist/_internal/platform/integrations/index.d.ts.map +1 -1
- package/dist/_internal/platform/integrations/index.js +1 -1
- package/dist/_internal/platform/integrations/ntfy.d.ts +11 -0
- package/dist/_internal/platform/integrations/ntfy.d.ts.map +1 -1
- package/dist/_internal/platform/integrations/ntfy.js +266 -30
- package/dist/_internal/platform/providers/registry.d.ts +1 -0
- package/dist/_internal/platform/providers/registry.d.ts.map +1 -1
- package/dist/_internal/platform/providers/registry.js +15 -5
- package/dist/_internal/platform/runtime/emitters/agents.d.ts +3 -0
- package/dist/_internal/platform/runtime/emitters/agents.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/events/agents.d.ts +3 -0
- package/dist/_internal/platform/runtime/events/agents.d.ts.map +1 -1
- package/dist/_internal/platform/tools/agent/manager.d.ts.map +1 -1
- package/dist/_internal/platform/tools/agent/manager.js +3 -0
- package/dist/_internal/platform/version.js +1 -1
- package/package.json +1 -1
- package/dist/_internal/platform/runtime/contracts/index.d.ts +0 -40
- package/dist/_internal/platform/runtime/contracts/index.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/index.js +0 -133
- package/dist/_internal/platform/runtime/contracts/migrations/index.d.ts +0 -75
- package/dist/_internal/platform/runtime/contracts/migrations/index.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/migrations/index.js +0 -158
- package/dist/_internal/platform/runtime/contracts/migrations/schemas.d.ts +0 -57
- package/dist/_internal/platform/runtime/contracts/migrations/schemas.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/migrations/schemas.js +0 -157
- package/dist/_internal/platform/runtime/contracts/types.d.ts +0 -123
- package/dist/_internal/platform/runtime/contracts/types.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/types.js +0 -41
- package/dist/_internal/platform/runtime/contracts/validators/event-envelope.d.ts +0 -24
- package/dist/_internal/platform/runtime/contracts/validators/event-envelope.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/validators/event-envelope.js +0 -104
- package/dist/_internal/platform/runtime/contracts/validators/index.d.ts +0 -11
- package/dist/_internal/platform/runtime/contracts/validators/index.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/validators/index.js +0 -10
- package/dist/_internal/platform/runtime/contracts/validators/runtime-state.d.ts +0 -23
- package/dist/_internal/platform/runtime/contracts/validators/runtime-state.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/validators/runtime-state.js +0 -101
- package/dist/_internal/platform/runtime/contracts/validators/session.d.ts +0 -24
- package/dist/_internal/platform/runtime/contracts/validators/session.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/validators/session.js +0 -103
- package/dist/_internal/platform/runtime/contracts/version.d.ts +0 -84
- package/dist/_internal/platform/runtime/contracts/version.d.ts.map +0 -1
- package/dist/_internal/platform/runtime/contracts/version.js +0 -41
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatibility Contracts — Module barrel and factory
|
|
3
|
-
*
|
|
4
|
-
* Entry point for the schema versioning, validation, and migration
|
|
5
|
-
* infrastructure. Use `createContractRegistry()` to obtain a fully
|
|
6
|
-
* initialized registry with all domain contracts registered.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { createContractRegistry } from './contracts/index.js';
|
|
11
|
-
* const { registry, contracts } = createContractRegistry();
|
|
12
|
-
* const result = contracts.get('runtimeState')?.validate(rawData);
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* @module contracts
|
|
16
|
-
*/
|
|
17
|
-
export { MigrationRegistry } from './migrations/index.js';
|
|
18
|
-
export * from './types.js';
|
|
19
|
-
export * from './version.js';
|
|
20
|
-
export * from './validators/index.js';
|
|
21
|
-
import { MigrationRegistry } from './migrations/index.js';
|
|
22
|
-
import { SCHEMA_VERSIONS, MIN_SUPPORTED_VERSIONS } from './version.js';
|
|
23
|
-
import { getRuntimeStateMigrationSteps, getEventEnvelopeMigrationSteps, getSessionMigrationSteps, getPluginManifestMigrationSteps, getTaskRecordMigrationSteps, } from './migrations/schemas.js';
|
|
24
|
-
import { validateRuntimeState } from './validators/runtime-state.js';
|
|
25
|
-
import { validateEventEnvelope } from './validators/event-envelope.js';
|
|
26
|
-
import { validateSession } from './validators/session.js';
|
|
27
|
-
/**
|
|
28
|
-
* Creates a fully initialized contract registry with all domain migration
|
|
29
|
-
* steps registered and SchemaContract instances built for each domain.
|
|
30
|
-
*
|
|
31
|
-
* Each SchemaContract provides:
|
|
32
|
-
* - `validate(data)` — runtime shape validation returning a ValidationResult
|
|
33
|
-
* - `migrate(data, fromVersion)` — migration chain execution via MigrationRegistry
|
|
34
|
-
*
|
|
35
|
-
* @returns An object containing:
|
|
36
|
-
* - `registry` — the MigrationRegistry with all steps registered
|
|
37
|
-
* - `contracts` — a Map of contract name → SchemaContract
|
|
38
|
-
*/
|
|
39
|
-
export function createContractRegistry() {
|
|
40
|
-
const registry = new MigrationRegistry();
|
|
41
|
-
// Register all domain migration steps
|
|
42
|
-
for (const step of getRuntimeStateMigrationSteps()) {
|
|
43
|
-
registry.register('runtimeState', step);
|
|
44
|
-
}
|
|
45
|
-
for (const step of getEventEnvelopeMigrationSteps()) {
|
|
46
|
-
registry.register('eventEnvelope', step);
|
|
47
|
-
}
|
|
48
|
-
for (const step of getSessionMigrationSteps()) {
|
|
49
|
-
registry.register('session', step);
|
|
50
|
-
}
|
|
51
|
-
for (const step of getPluginManifestMigrationSteps()) {
|
|
52
|
-
registry.register('pluginManifest', step);
|
|
53
|
-
}
|
|
54
|
-
for (const step of getTaskRecordMigrationSteps()) {
|
|
55
|
-
registry.register('taskRecord', step);
|
|
56
|
-
}
|
|
57
|
-
const contracts = new Map();
|
|
58
|
-
// runtimeState contract
|
|
59
|
-
contracts.set('runtimeState', {
|
|
60
|
-
name: 'runtimeState',
|
|
61
|
-
currentVersion: SCHEMA_VERSIONS.runtimeState,
|
|
62
|
-
minSupportedVersion: MIN_SUPPORTED_VERSIONS.runtimeState,
|
|
63
|
-
validate: validateRuntimeState,
|
|
64
|
-
migrate: (data, fromVersion) => registry.migrate('runtimeState', data, fromVersion),
|
|
65
|
-
});
|
|
66
|
-
// eventEnvelope contract
|
|
67
|
-
contracts.set('eventEnvelope', {
|
|
68
|
-
name: 'eventEnvelope',
|
|
69
|
-
currentVersion: SCHEMA_VERSIONS.eventEnvelope,
|
|
70
|
-
minSupportedVersion: MIN_SUPPORTED_VERSIONS.eventEnvelope,
|
|
71
|
-
validate: validateEventEnvelope,
|
|
72
|
-
migrate: (data, fromVersion) => registry.migrate('eventEnvelope', data, fromVersion),
|
|
73
|
-
});
|
|
74
|
-
// session contract
|
|
75
|
-
contracts.set('session', {
|
|
76
|
-
name: 'session',
|
|
77
|
-
currentVersion: SCHEMA_VERSIONS.session,
|
|
78
|
-
minSupportedVersion: MIN_SUPPORTED_VERSIONS.session,
|
|
79
|
-
validate: validateSession,
|
|
80
|
-
migrate: (data, fromVersion) => registry.migrate('session', data, fromVersion),
|
|
81
|
-
});
|
|
82
|
-
// pluginManifest contract
|
|
83
|
-
contracts.set('pluginManifest', {
|
|
84
|
-
name: 'pluginManifest',
|
|
85
|
-
currentVersion: SCHEMA_VERSIONS.pluginManifest,
|
|
86
|
-
minSupportedVersion: MIN_SUPPORTED_VERSIONS.pluginManifest,
|
|
87
|
-
validate: (data) => {
|
|
88
|
-
const errors = [];
|
|
89
|
-
if (data === null || typeof data !== 'object' || Array.isArray(data)) {
|
|
90
|
-
errors.push({ path: '', message: 'pluginManifest must be a non-null object', expected: 'object', actual: data === null ? 'null' : Array.isArray(data) ? 'array' : typeof data });
|
|
91
|
-
return { valid: false, errors };
|
|
92
|
-
}
|
|
93
|
-
const record = data;
|
|
94
|
-
if (typeof record['name'] !== 'string' || record['name'].length === 0) {
|
|
95
|
-
errors.push({ path: 'name', message: "Field 'name' must be a non-empty string", expected: 'non-empty string', actual: typeof record['name'] });
|
|
96
|
-
}
|
|
97
|
-
if (typeof record['version'] !== 'string' || record['version'].length === 0) {
|
|
98
|
-
errors.push({ path: 'version', message: "Field 'version' must be a non-empty string", expected: 'non-empty string', actual: typeof record['version'] });
|
|
99
|
-
}
|
|
100
|
-
if (!Array.isArray(record['capabilities'])) {
|
|
101
|
-
errors.push({ path: 'capabilities', message: "Field 'capabilities' must be an array", expected: 'array', actual: typeof record['capabilities'] });
|
|
102
|
-
}
|
|
103
|
-
return { valid: errors.length === 0, errors, version: SCHEMA_VERSIONS.pluginManifest };
|
|
104
|
-
},
|
|
105
|
-
migrate: (data, fromVersion) => registry.migrate('pluginManifest', data, fromVersion),
|
|
106
|
-
});
|
|
107
|
-
// taskRecord contract
|
|
108
|
-
contracts.set('taskRecord', {
|
|
109
|
-
name: 'taskRecord',
|
|
110
|
-
currentVersion: SCHEMA_VERSIONS.taskRecord,
|
|
111
|
-
minSupportedVersion: MIN_SUPPORTED_VERSIONS.taskRecord,
|
|
112
|
-
validate: (data) => {
|
|
113
|
-
const errors = [];
|
|
114
|
-
if (data === null || typeof data !== 'object' || Array.isArray(data)) {
|
|
115
|
-
errors.push({ path: '', message: 'taskRecord must be a non-null object', expected: 'object', actual: data === null ? 'null' : Array.isArray(data) ? 'array' : typeof data });
|
|
116
|
-
return { valid: false, errors };
|
|
117
|
-
}
|
|
118
|
-
const record = data;
|
|
119
|
-
if (typeof record['id'] !== 'string' || record['id'].length === 0) {
|
|
120
|
-
errors.push({ path: 'id', message: "Field 'id' must be a non-empty string", expected: 'non-empty string', actual: typeof record['id'] });
|
|
121
|
-
}
|
|
122
|
-
if (typeof record['type'] !== 'string' || record['type'].length === 0) {
|
|
123
|
-
errors.push({ path: 'type', message: "Field 'type' must be a non-empty string", expected: 'non-empty string', actual: typeof record['type'] });
|
|
124
|
-
}
|
|
125
|
-
if (typeof record['status'] !== 'string' || record['status'].length === 0) {
|
|
126
|
-
errors.push({ path: 'status', message: "Field 'status' must be a non-empty string", expected: 'non-empty string', actual: typeof record['status'] });
|
|
127
|
-
}
|
|
128
|
-
return { valid: errors.length === 0, errors, version: SCHEMA_VERSIONS.taskRecord };
|
|
129
|
-
},
|
|
130
|
-
migrate: (data, fromVersion) => registry.migrate('taskRecord', data, fromVersion),
|
|
131
|
-
});
|
|
132
|
-
return { registry, contracts };
|
|
133
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatibility Contracts — Migration Registry
|
|
3
|
-
*
|
|
4
|
-
* The MigrationRegistry holds all registered schema migration steps and
|
|
5
|
-
* provides path resolution and ordered execution for any version pair.
|
|
6
|
-
*
|
|
7
|
-
* @module contracts/migrations
|
|
8
|
-
*/
|
|
9
|
-
import { type MigrationStep, type MigrationResult, type SchemaVersion } from '../types.js';
|
|
10
|
-
/**
|
|
11
|
-
* Central registry for all schema migration steps.
|
|
12
|
-
*
|
|
13
|
-
* Migrations are registered per contract name and resolved as an ordered
|
|
14
|
-
* chain from a given source version to the current target version.
|
|
15
|
-
* All migration functions must be pure (no mutations, no side effects).
|
|
16
|
-
*/
|
|
17
|
-
export declare class MigrationRegistry {
|
|
18
|
-
private readonly steps;
|
|
19
|
-
/**
|
|
20
|
-
* Registers a migration step for a given contract.
|
|
21
|
-
*
|
|
22
|
-
* Steps are stored in insertion order and sorted at resolution time.
|
|
23
|
-
* Duplicate from→to pairs for the same contract are not permitted.
|
|
24
|
-
*
|
|
25
|
-
* @param contract - The contract name (e.g. 'runtimeState').
|
|
26
|
-
* @param step - The migration step to register.
|
|
27
|
-
* @throws If a step with the same from→to is already registered.
|
|
28
|
-
*/
|
|
29
|
-
register(contract: string, step: MigrationStep): void;
|
|
30
|
-
/**
|
|
31
|
-
* Returns true if any migration path exists from `fromVersion` toward
|
|
32
|
-
* a higher version for the given contract.
|
|
33
|
-
*
|
|
34
|
-
* @param contract - The contract name.
|
|
35
|
-
* @param fromVersion - The source schema version to migrate from.
|
|
36
|
-
*/
|
|
37
|
-
canMigrate(contract: string, fromVersion: SchemaVersion): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Resolves an ordered chain of migration steps from `from` to `to`.
|
|
40
|
-
*
|
|
41
|
-
* Uses a greedy forward walk: at each version, finds the step that advances
|
|
42
|
-
* closest to the target. Throws if no complete path exists.
|
|
43
|
-
*
|
|
44
|
-
* @param contract - The contract name.
|
|
45
|
-
* @param from - The starting schema version.
|
|
46
|
-
* @param to - The target schema version.
|
|
47
|
-
* @returns Ordered array of MigrationSteps forming the complete path.
|
|
48
|
-
* @throws If no migration path exists between the two versions.
|
|
49
|
-
*/
|
|
50
|
-
getMigrationPath(contract: string, from: SchemaVersion, to: SchemaVersion): MigrationStep[];
|
|
51
|
-
/**
|
|
52
|
-
* Migrates data from `fromVersion` to the latest version reachable via
|
|
53
|
-
* registered steps for the given contract.
|
|
54
|
-
*
|
|
55
|
-
* If `fromVersion` already matches the end of the migration chain,
|
|
56
|
-
* the data is returned as-is without transformation.
|
|
57
|
-
*
|
|
58
|
-
* @param contract - The contract name.
|
|
59
|
-
* @param data - The raw data to migrate.
|
|
60
|
-
* @param fromVersion - The schema version of the incoming data.
|
|
61
|
-
* @returns The migrated data and the version it was migrated to.
|
|
62
|
-
* @throws If the migration path is incomplete or a step throws.
|
|
63
|
-
*/
|
|
64
|
-
migrate(contract: string, data: unknown, fromVersion: SchemaVersion): MigrationResult;
|
|
65
|
-
/**
|
|
66
|
-
* Resolves the highest version reachable from `fromVersion` by following
|
|
67
|
-
* the chain of registered steps.
|
|
68
|
-
*/
|
|
69
|
-
private _resolveLatestVersion;
|
|
70
|
-
/**
|
|
71
|
-
* Returns all registered contract names.
|
|
72
|
-
*/
|
|
73
|
-
contractNames(): string[];
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/runtime/contracts/migrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAInB,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsC;IAE5D;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;IAiBrD;;;;;;OAMG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,GAAG,OAAO;IAKjE;;;;;;;;;;;OAWG;IACH,gBAAgB,CACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,aAAa,EACnB,EAAE,EAAE,aAAa,GAChB,aAAa,EAAE;IAqDlB;;;;;;;;;;;;OAYG;IACH,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,aAAa,GACzB,eAAe;IAiBlB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAwB7B;;OAEG;IACH,aAAa,IAAI,MAAM,EAAE;CAG1B"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatibility Contracts — Migration Registry
|
|
3
|
-
*
|
|
4
|
-
* The MigrationRegistry holds all registered schema migration steps and
|
|
5
|
-
* provides path resolution and ordered execution for any version pair.
|
|
6
|
-
*
|
|
7
|
-
* @module contracts/migrations
|
|
8
|
-
*/
|
|
9
|
-
import { compareVersions, versionsEqual, versionToString, } from '../types.js';
|
|
10
|
-
/**
|
|
11
|
-
* Central registry for all schema migration steps.
|
|
12
|
-
*
|
|
13
|
-
* Migrations are registered per contract name and resolved as an ordered
|
|
14
|
-
* chain from a given source version to the current target version.
|
|
15
|
-
* All migration functions must be pure (no mutations, no side effects).
|
|
16
|
-
*/
|
|
17
|
-
export class MigrationRegistry {
|
|
18
|
-
steps = new Map();
|
|
19
|
-
/**
|
|
20
|
-
* Registers a migration step for a given contract.
|
|
21
|
-
*
|
|
22
|
-
* Steps are stored in insertion order and sorted at resolution time.
|
|
23
|
-
* Duplicate from→to pairs for the same contract are not permitted.
|
|
24
|
-
*
|
|
25
|
-
* @param contract - The contract name (e.g. 'runtimeState').
|
|
26
|
-
* @param step - The migration step to register.
|
|
27
|
-
* @throws If a step with the same from→to is already registered.
|
|
28
|
-
*/
|
|
29
|
-
register(contract, step) {
|
|
30
|
-
if (!this.steps.has(contract)) {
|
|
31
|
-
this.steps.set(contract, []);
|
|
32
|
-
}
|
|
33
|
-
const existing = this.steps.get(contract);
|
|
34
|
-
const duplicate = existing.find((s) => versionsEqual(s.from, step.from) && versionsEqual(s.to, step.to));
|
|
35
|
-
if (duplicate) {
|
|
36
|
-
throw new Error(`Duplicate migration step for contract '${contract}': ` +
|
|
37
|
-
`${versionToString(step.from)} → ${versionToString(step.to)}`);
|
|
38
|
-
}
|
|
39
|
-
existing.push(step);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Returns true if any migration path exists from `fromVersion` toward
|
|
43
|
-
* a higher version for the given contract.
|
|
44
|
-
*
|
|
45
|
-
* @param contract - The contract name.
|
|
46
|
-
* @param fromVersion - The source schema version to migrate from.
|
|
47
|
-
*/
|
|
48
|
-
canMigrate(contract, fromVersion) {
|
|
49
|
-
const steps = this.steps.get(contract) ?? [];
|
|
50
|
-
return steps.some((s) => versionsEqual(s.from, fromVersion));
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Resolves an ordered chain of migration steps from `from` to `to`.
|
|
54
|
-
*
|
|
55
|
-
* Uses a greedy forward walk: at each version, finds the step that advances
|
|
56
|
-
* closest to the target. Throws if no complete path exists.
|
|
57
|
-
*
|
|
58
|
-
* @param contract - The contract name.
|
|
59
|
-
* @param from - The starting schema version.
|
|
60
|
-
* @param to - The target schema version.
|
|
61
|
-
* @returns Ordered array of MigrationSteps forming the complete path.
|
|
62
|
-
* @throws If no migration path exists between the two versions.
|
|
63
|
-
*/
|
|
64
|
-
getMigrationPath(contract, from, to) {
|
|
65
|
-
if (versionsEqual(from, to))
|
|
66
|
-
return [];
|
|
67
|
-
if (compareVersions(from, to) > 0) {
|
|
68
|
-
throw new Error(`Downgrade migration is not supported for contract '${contract}': ` +
|
|
69
|
-
`cannot migrate from ${versionToString(from)} to ${versionToString(to)}`);
|
|
70
|
-
}
|
|
71
|
-
const allSteps = this.steps.get(contract) ?? [];
|
|
72
|
-
const path = [];
|
|
73
|
-
let current = from;
|
|
74
|
-
while (!versionsEqual(current, to)) {
|
|
75
|
-
// Find all steps that start from the current version
|
|
76
|
-
const candidates = allSteps.filter((s) => versionsEqual(s.from, current));
|
|
77
|
-
if (candidates.length === 0) {
|
|
78
|
-
throw new Error(`No migration step found for contract '${contract}' ` +
|
|
79
|
-
`at version ${versionToString(current)} (target: ${versionToString(to)})`);
|
|
80
|
-
}
|
|
81
|
-
// Pick the step that advances closest to the target without overshooting
|
|
82
|
-
const step = candidates.reduce((best, candidate) => {
|
|
83
|
-
const cmpBest = compareVersions(best.to, to);
|
|
84
|
-
const cmpCandidate = compareVersions(candidate.to, to);
|
|
85
|
-
// Prefer steps that don't overshoot; among those, prefer the one closest to target
|
|
86
|
-
if (cmpBest > 0 && cmpCandidate <= 0)
|
|
87
|
-
return candidate;
|
|
88
|
-
if (cmpCandidate > 0 && cmpBest <= 0)
|
|
89
|
-
return best;
|
|
90
|
-
return compareVersions(candidate.to, best.to) > 0 ? candidate : best;
|
|
91
|
-
});
|
|
92
|
-
if (compareVersions(step.to, current) <= 0) {
|
|
93
|
-
throw new Error(`Migration step for contract '${contract}' does not advance version: ` +
|
|
94
|
-
`${versionToString(step.from)} → ${versionToString(step.to)}`);
|
|
95
|
-
}
|
|
96
|
-
path.push(step);
|
|
97
|
-
current = step.to;
|
|
98
|
-
if (path.length > 100) {
|
|
99
|
-
throw new Error(`Migration path for contract '${contract}' exceeded 100 steps — possible cycle detected`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return path;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Migrates data from `fromVersion` to the latest version reachable via
|
|
106
|
-
* registered steps for the given contract.
|
|
107
|
-
*
|
|
108
|
-
* If `fromVersion` already matches the end of the migration chain,
|
|
109
|
-
* the data is returned as-is without transformation.
|
|
110
|
-
*
|
|
111
|
-
* @param contract - The contract name.
|
|
112
|
-
* @param data - The raw data to migrate.
|
|
113
|
-
* @param fromVersion - The schema version of the incoming data.
|
|
114
|
-
* @returns The migrated data and the version it was migrated to.
|
|
115
|
-
* @throws If the migration path is incomplete or a step throws.
|
|
116
|
-
*/
|
|
117
|
-
migrate(contract, data, fromVersion) {
|
|
118
|
-
// Find the highest reachable version from this starting point
|
|
119
|
-
const targetVersion = this._resolveLatestVersion(contract, fromVersion);
|
|
120
|
-
if (versionsEqual(fromVersion, targetVersion)) {
|
|
121
|
-
return { data, version: fromVersion };
|
|
122
|
-
}
|
|
123
|
-
const path = this.getMigrationPath(contract, fromVersion, targetVersion);
|
|
124
|
-
let current = data;
|
|
125
|
-
for (const step of path) {
|
|
126
|
-
current = step.migrate(current);
|
|
127
|
-
}
|
|
128
|
-
return { data: current, version: targetVersion };
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Resolves the highest version reachable from `fromVersion` by following
|
|
132
|
-
* the chain of registered steps.
|
|
133
|
-
*/
|
|
134
|
-
_resolveLatestVersion(contract, fromVersion) {
|
|
135
|
-
const allSteps = this.steps.get(contract) ?? [];
|
|
136
|
-
let current = fromVersion;
|
|
137
|
-
const visited = new Set();
|
|
138
|
-
while (true) {
|
|
139
|
-
const key = versionToString(current);
|
|
140
|
-
if (visited.has(key))
|
|
141
|
-
break;
|
|
142
|
-
visited.add(key);
|
|
143
|
-
const next = allSteps
|
|
144
|
-
.filter((s) => versionsEqual(s.from, current))
|
|
145
|
-
.sort((a, b) => compareVersions(b.to, a.to))[0];
|
|
146
|
-
if (!next)
|
|
147
|
-
break;
|
|
148
|
-
current = next.to;
|
|
149
|
-
}
|
|
150
|
-
return current;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Returns all registered contract names.
|
|
154
|
-
*/
|
|
155
|
-
contractNames() {
|
|
156
|
-
return [...this.steps.keys()];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
@@ -1,57 +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 type { MigrationStep } from '../types.js';
|
|
17
|
-
/** The current EventEnvelope schema version (re-exported for convenience). */
|
|
18
|
-
export declare const EVENT_ENVELOPE_VERSION: {
|
|
19
|
-
readonly major: 1;
|
|
20
|
-
readonly minor: 1;
|
|
21
|
-
readonly patch: 0;
|
|
22
|
-
};
|
|
23
|
-
/** Returns all EventEnvelope migration steps. Used by the contract registry. */
|
|
24
|
-
export declare function getEventEnvelopeMigrationSteps(): MigrationStep[];
|
|
25
|
-
/** The current PluginManifest schema version (re-exported for convenience). */
|
|
26
|
-
export declare const PLUGIN_MANIFEST_VERSION: {
|
|
27
|
-
readonly major: 1;
|
|
28
|
-
readonly minor: 0;
|
|
29
|
-
readonly patch: 0;
|
|
30
|
-
};
|
|
31
|
-
/** Returns all PluginManifest migration steps. Used by the contract registry. */
|
|
32
|
-
export declare function getPluginManifestMigrationSteps(): MigrationStep[];
|
|
33
|
-
/** The current RuntimeState schema version (re-exported for convenience). */
|
|
34
|
-
export declare const RUNTIME_STATE_VERSION: {
|
|
35
|
-
readonly major: 1;
|
|
36
|
-
readonly minor: 0;
|
|
37
|
-
readonly patch: 0;
|
|
38
|
-
};
|
|
39
|
-
/** Returns all RuntimeState migration steps. Used by the contract registry. */
|
|
40
|
-
export declare function getRuntimeStateMigrationSteps(): MigrationStep[];
|
|
41
|
-
/** The current Session schema version (re-exported for convenience). */
|
|
42
|
-
export declare const SESSION_VERSION: {
|
|
43
|
-
readonly major: 1;
|
|
44
|
-
readonly minor: 0;
|
|
45
|
-
readonly patch: 0;
|
|
46
|
-
};
|
|
47
|
-
/** Returns all Session migration steps. Used by the contract registry. */
|
|
48
|
-
export declare function getSessionMigrationSteps(): MigrationStep[];
|
|
49
|
-
/** The current TaskRecord schema version (re-exported for convenience). */
|
|
50
|
-
export declare const TASK_RECORD_VERSION: {
|
|
51
|
-
readonly major: 1;
|
|
52
|
-
readonly minor: 0;
|
|
53
|
-
readonly patch: 0;
|
|
54
|
-
};
|
|
55
|
-
/** Returns all TaskRecord migration steps. Used by the contract registry. */
|
|
56
|
-
export declare function getTaskRecordMigrationSteps(): MigrationStep[];
|
|
57
|
-
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/runtime/contracts/migrations/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA2BjD,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB;;;;CAAgC,CAAC;AAEpE,gFAAgF;AAChF,wBAAgB,8BAA8B,IAAI,aAAa,EAAE,CAEhE;AA0BD,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB;;;;CAAiC,CAAC;AAEtE,iFAAiF;AACjF,wBAAgB,+BAA+B,IAAI,aAAa,EAAE,CAEjE;AA0BD,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB;;;;CAA+B,CAAC;AAElE,+EAA+E;AAC/E,wBAAgB,6BAA6B,IAAI,aAAa,EAAE,CAE/D;AA2BD,wEAAwE;AACxE,eAAO,MAAM,eAAe;;;;CAA0B,CAAC;AAEvD,0EAA0E;AAC1E,wBAAgB,wBAAwB,IAAI,aAAa,EAAE,CAE1D;AA0BD,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB;;;;CAA6B,CAAC;AAE9D,6EAA6E;AAC7E,wBAAgB,2BAA2B,IAAI,aAAa,EAAE,CAE7D"}
|
|
@@ -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
|
-
}
|