@agents-uni/core 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/DESIGN.md +283 -0
- package/LICENSE +21 -0
- package/README.en.md +589 -0
- package/README.md +589 -0
- package/dist/bridge/config-sync.d.ts +24 -0
- package/dist/bridge/config-sync.d.ts.map +1 -0
- package/dist/bridge/config-sync.js +39 -0
- package/dist/bridge/config-sync.js.map +1 -0
- package/dist/bridge/index.d.ts +7 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +7 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/openclaw-adapter.d.ts +49 -0
- package/dist/bridge/openclaw-adapter.d.ts.map +1 -0
- package/dist/bridge/openclaw-adapter.js +151 -0
- package/dist/bridge/openclaw-adapter.js.map +1 -0
- package/dist/bridge/soul-generator.d.ts +34 -0
- package/dist/bridge/soul-generator.d.ts.map +1 -0
- package/dist/bridge/soul-generator.js +149 -0
- package/dist/bridge/soul-generator.js.map +1 -0
- package/dist/bridge/task-dispatcher.d.ts +107 -0
- package/dist/bridge/task-dispatcher.d.ts.map +1 -0
- package/dist/bridge/task-dispatcher.js +217 -0
- package/dist/bridge/task-dispatcher.js.map +1 -0
- package/dist/bridge/uni-registry.d.ts +82 -0
- package/dist/bridge/uni-registry.d.ts.map +1 -0
- package/dist/bridge/uni-registry.js +261 -0
- package/dist/bridge/uni-registry.js.map +1 -0
- package/dist/bridge/workspace-io.d.ts +64 -0
- package/dist/bridge/workspace-io.d.ts.map +1 -0
- package/dist/bridge/workspace-io.js +99 -0
- package/dist/bridge/workspace-io.js.map +1 -0
- package/dist/cli/commands/deploy.d.ts +6 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +48 -0
- package/dist/cli/commands/deploy.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +137 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/inspect.d.ts +4 -0
- package/dist/cli/commands/inspect.d.ts.map +1 -0
- package/dist/cli/commands/inspect.js +77 -0
- package/dist/cli/commands/inspect.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +2 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +30 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/commands/visualize.d.ts +2 -0
- package/dist/cli/commands/visualize.d.ts.map +1 -0
- package/dist/cli/commands/visualize.js +69 -0
- package/dist/cli/commands/visualize.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +132 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/agent-registry.d.ts +37 -0
- package/dist/core/agent-registry.d.ts.map +1 -0
- package/dist/core/agent-registry.js +97 -0
- package/dist/core/agent-registry.js.map +1 -0
- package/dist/core/event-bus.d.ts +34 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +96 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +8 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/permission-matrix.d.ts +35 -0
- package/dist/core/permission-matrix.d.ts.map +1 -0
- package/dist/core/permission-matrix.js +95 -0
- package/dist/core/permission-matrix.js.map +1 -0
- package/dist/core/relationship-graph.d.ts +50 -0
- package/dist/core/relationship-graph.d.ts.map +1 -0
- package/dist/core/relationship-graph.js +150 -0
- package/dist/core/relationship-graph.js.map +1 -0
- package/dist/core/resource-pool.d.ts +48 -0
- package/dist/core/resource-pool.d.ts.map +1 -0
- package/dist/core/resource-pool.js +205 -0
- package/dist/core/resource-pool.js.map +1 -0
- package/dist/core/state-machine.d.ts +47 -0
- package/dist/core/state-machine.d.ts.map +1 -0
- package/dist/core/state-machine.js +110 -0
- package/dist/core/state-machine.js.map +1 -0
- package/dist/core/universe.d.ts +38 -0
- package/dist/core/universe.d.ts.map +1 -0
- package/dist/core/universe.js +101 -0
- package/dist/core/universe.js.map +1 -0
- package/dist/dashboard/api.d.ts +10 -0
- package/dist/dashboard/api.d.ts.map +1 -0
- package/dist/dashboard/api.js +237 -0
- package/dist/dashboard/api.js.map +1 -0
- package/dist/dashboard/index.d.ts +3 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +3 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/dashboard/server.d.ts +31 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/dashboard/server.js +44 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/dashboard/templates.d.ts +47 -0
- package/dist/dashboard/templates.d.ts.map +1 -0
- package/dist/dashboard/templates.js +1481 -0
- package/dist/dashboard/templates.js.map +1 -0
- package/dist/evolution/index.d.ts +5 -0
- package/dist/evolution/index.d.ts.map +1 -0
- package/dist/evolution/index.js +5 -0
- package/dist/evolution/index.js.map +1 -0
- package/dist/evolution/memory-consolidator.d.ts +28 -0
- package/dist/evolution/memory-consolidator.d.ts.map +1 -0
- package/dist/evolution/memory-consolidator.js +84 -0
- package/dist/evolution/memory-consolidator.js.map +1 -0
- package/dist/evolution/performance-tracker.d.ts +29 -0
- package/dist/evolution/performance-tracker.d.ts.map +1 -0
- package/dist/evolution/performance-tracker.js +90 -0
- package/dist/evolution/performance-tracker.js.map +1 -0
- package/dist/evolution/promotion-engine.d.ts +32 -0
- package/dist/evolution/promotion-engine.d.ts.map +1 -0
- package/dist/evolution/promotion-engine.js +117 -0
- package/dist/evolution/promotion-engine.js.map +1 -0
- package/dist/evolution/relationship-evolver.d.ts +40 -0
- package/dist/evolution/relationship-evolver.d.ts.map +1 -0
- package/dist/evolution/relationship-evolver.js +105 -0
- package/dist/evolution/relationship-evolver.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/schema/index.d.ts +13 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +18 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/universe.schema.json +214 -0
- package/dist/spec/compiler.d.ts +16 -0
- package/dist/spec/compiler.d.ts.map +1 -0
- package/dist/spec/compiler.js +26 -0
- package/dist/spec/compiler.js.map +1 -0
- package/dist/spec/index.d.ts +4 -0
- package/dist/spec/index.d.ts.map +1 -0
- package/dist/spec/index.js +4 -0
- package/dist/spec/index.js.map +1 -0
- package/dist/spec/parser.d.ts +11 -0
- package/dist/spec/parser.d.ts.map +1 -0
- package/dist/spec/parser.js +89 -0
- package/dist/spec/parser.js.map +1 -0
- package/dist/spec/validator.d.ts +9 -0
- package/dist/spec/validator.d.ts.map +1 -0
- package/dist/spec/validator.js +105 -0
- package/dist/spec/validator.js.map +1 -0
- package/dist/types/agent.d.ts +56 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +8 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/event.d.ts +34 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +11 -0
- package/dist/types/event.js.map +1 -0
- package/dist/types/governance.d.ts +48 -0
- package/dist/types/governance.d.ts.map +1 -0
- package/dist/types/governance.js +9 -0
- package/dist/types/governance.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/memory.d.ts +73 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +9 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/types/protocol.d.ts +48 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/protocol.js +9 -0
- package/dist/types/protocol.js.map +1 -0
- package/dist/types/relationship.d.ts +40 -0
- package/dist/types/relationship.d.ts.map +1 -0
- package/dist/types/relationship.js +9 -0
- package/dist/types/relationship.js.map +1 -0
- package/dist/types/resource.d.ts +52 -0
- package/dist/types/resource.d.ts.map +1 -0
- package/dist/types/resource.js +9 -0
- package/dist/types/resource.js.map +1 -0
- package/dist/types/universe.d.ts +71 -0
- package/dist/types/universe.d.ts.map +1 -0
- package/dist/types/universe.js +9 -0
- package/dist/types/universe.js.map +1 -0
- package/package.json +68 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agents-uni-core — Universal protocol layer for agent organizations.
|
|
3
|
+
*
|
|
4
|
+
* Core mission: 提升生产力的同时,我们需要的是更优秀的生产关系。
|
|
5
|
+
* (While improving productivity, what we need is better production relationships.)
|
|
6
|
+
*
|
|
7
|
+
* @module agents-uni-core
|
|
8
|
+
*/
|
|
9
|
+
export * from './types/index.js';
|
|
10
|
+
export { Universe, AgentRegistry, RelationshipGraph, StateMachine, PermissionMatrix, ResourcePool, EventBus, } from './core/index.js';
|
|
11
|
+
export type { StateMachineInstance, TransitionRecord } from './core/index.js';
|
|
12
|
+
export { PerformanceTracker, PromotionEngine, MemoryConsolidator, RelationshipEvolver, } from './evolution/index.js';
|
|
13
|
+
export type { PromotionDecision, RelationshipChange } from './evolution/index.js';
|
|
14
|
+
export { parseSpecFile, parseSpecString, validateSpec, compileUniverse } from './spec/index.js';
|
|
15
|
+
export { generateSoul, generateAllSouls, deployToOpenClaw, registerAgentsInOpenClaw, checkWorkspaces, TaskDispatcher, FileWorkspaceIO, MemoryWorkspaceIO, registerUni, listUnis, getUni, unregisterUni, cleanupUni, updateUni, resetUni, } from './bridge/index.js';
|
|
16
|
+
export type { SoulGeneratorOptions, RulerDefinition, DeployOptions, DeployResult, DispatchTask, AgentSubmission, DispatchResult, DispatcherOptions, WorkspaceIO, EvaluationCriterion, UniRegistryEntry, UniRegistry, } from './bridge/index.js';
|
|
17
|
+
export { startDashboard, createDashboardRoutes, } from './dashboard/index.js';
|
|
18
|
+
export type { DashboardConfig, DashboardExtension, PanelDefinition, } from './dashboard/index.js';
|
|
19
|
+
export { validateUniverseSpec } from './schema/index.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGlF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGhG,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,MAAM,EACN,aAAa,EACb,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agents-uni-core — Universal protocol layer for agent organizations.
|
|
3
|
+
*
|
|
4
|
+
* Core mission: 提升生产力的同时,我们需要的是更优秀的生产关系。
|
|
5
|
+
* (While improving productivity, what we need is better production relationships.)
|
|
6
|
+
*
|
|
7
|
+
* @module agents-uni-core
|
|
8
|
+
*/
|
|
9
|
+
// Types (the "language" of agent organizations)
|
|
10
|
+
export * from './types/index.js';
|
|
11
|
+
// Core runtime engine
|
|
12
|
+
export { Universe, AgentRegistry, RelationshipGraph, StateMachine, PermissionMatrix, ResourcePool, EventBus, } from './core/index.js';
|
|
13
|
+
// Evolution engine
|
|
14
|
+
export { PerformanceTracker, PromotionEngine, MemoryConsolidator, RelationshipEvolver, } from './evolution/index.js';
|
|
15
|
+
// Spec processing
|
|
16
|
+
export { parseSpecFile, parseSpecString, validateSpec, compileUniverse } from './spec/index.js';
|
|
17
|
+
// OpenClaw bridge
|
|
18
|
+
export { generateSoul, generateAllSouls, deployToOpenClaw, registerAgentsInOpenClaw, checkWorkspaces, TaskDispatcher, FileWorkspaceIO, MemoryWorkspaceIO, registerUni, listUnis, getUni, unregisterUni, cleanupUni, updateUni, resetUni, } from './bridge/index.js';
|
|
19
|
+
// Dashboard
|
|
20
|
+
export { startDashboard, createDashboardRoutes, } from './dashboard/index.js';
|
|
21
|
+
// Schema
|
|
22
|
+
export { validateUniverseSpec } from './schema/index.js';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,gDAAgD;AAChD,cAAc,kBAAkB,CAAC;AAEjC,sBAAsB;AACtB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAGzB,mBAAmB;AACnB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAG9B,kBAAkB;AAClB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEhG,kBAAkB;AAClB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,MAAM,EACN,aAAa,EACb,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAgB3B,YAAY;AACZ,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAO9B,SAAS;AACT,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import universeSchema from './universe.schema.json';
|
|
2
|
+
export interface ValidationResult {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
errors: ValidationError[];
|
|
5
|
+
}
|
|
6
|
+
export interface ValidationError {
|
|
7
|
+
path: string;
|
|
8
|
+
message: string;
|
|
9
|
+
keyword: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function validateUniverseSpec(data: unknown): ValidationResult;
|
|
12
|
+
export { universeSchema };
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,MAAM,wBAAwB,CAAuB;AAM1E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAcpE;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import universeSchema from './universe.schema.json' with { type: 'json' };
|
|
3
|
+
const ajv = new Ajv({ allErrors: true, verbose: true, validateSchema: false });
|
|
4
|
+
const validateUniverse = ajv.compile(universeSchema);
|
|
5
|
+
export function validateUniverseSpec(data) {
|
|
6
|
+
const valid = validateUniverse(data);
|
|
7
|
+
if (valid) {
|
|
8
|
+
return { valid: true, errors: [] };
|
|
9
|
+
}
|
|
10
|
+
const errors = (validateUniverse.errors ?? []).map(err => ({
|
|
11
|
+
path: err.instancePath || '/',
|
|
12
|
+
message: err.message ?? 'Unknown validation error',
|
|
13
|
+
keyword: err.keyword,
|
|
14
|
+
}));
|
|
15
|
+
return { valid: false, errors };
|
|
16
|
+
}
|
|
17
|
+
export { universeSchema };
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,cAAc,MAAM,wBAAwB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE1E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;AAE/E,MAAM,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AAarD,MAAM,UAAU,oBAAoB,CAAC,IAAa;IAChD,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAErC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACrC,CAAC;IAED,MAAM,MAAM,GAAsB,CAAC,gBAAgB,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5E,IAAI,EAAE,GAAG,CAAC,YAAY,IAAI,GAAG;QAC7B,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,0BAA0B;QAClD,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC,CAAC,CAAC;IAEJ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://agents-uni-core/universe.schema.json",
|
|
4
|
+
"title": "Universe Specification",
|
|
5
|
+
"description": "Schema for defining agent organization universes",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["name", "version", "description", "type", "agents", "relationships", "protocols", "governance"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"pattern": "^[a-z0-9-]+$",
|
|
12
|
+
"description": "Universe name (kebab-case)"
|
|
13
|
+
},
|
|
14
|
+
"version": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
|
|
17
|
+
},
|
|
18
|
+
"description": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
},
|
|
21
|
+
"type": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"enum": ["hierarchical", "flat", "competitive", "hybrid"]
|
|
24
|
+
},
|
|
25
|
+
"agents": {
|
|
26
|
+
"type": "array",
|
|
27
|
+
"minItems": 1,
|
|
28
|
+
"items": { "$ref": "#/$defs/agent" }
|
|
29
|
+
},
|
|
30
|
+
"relationships": {
|
|
31
|
+
"type": "array",
|
|
32
|
+
"items": { "$ref": "#/$defs/relationship" }
|
|
33
|
+
},
|
|
34
|
+
"protocols": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"minItems": 1,
|
|
37
|
+
"items": { "$ref": "#/$defs/protocol" }
|
|
38
|
+
},
|
|
39
|
+
"governance": { "$ref": "#/$defs/governance" },
|
|
40
|
+
"resources": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"items": { "$ref": "#/$defs/resource" }
|
|
43
|
+
},
|
|
44
|
+
"evolution": { "$ref": "#/$defs/evolution" },
|
|
45
|
+
"metadata": {
|
|
46
|
+
"type": "object"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"$defs": {
|
|
50
|
+
"agent": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"required": ["id", "name", "role"],
|
|
53
|
+
"properties": {
|
|
54
|
+
"id": { "type": "string", "pattern": "^[a-z0-9_-]+$" },
|
|
55
|
+
"name": { "type": "string" },
|
|
56
|
+
"role": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"required": ["title", "duties", "permissions"],
|
|
59
|
+
"properties": {
|
|
60
|
+
"title": { "type": "string" },
|
|
61
|
+
"department": { "type": "string" },
|
|
62
|
+
"duties": { "type": "array", "items": { "type": "string" } },
|
|
63
|
+
"permissions": { "type": "array", "items": { "type": "string" } },
|
|
64
|
+
"soulTemplate": { "type": "string" }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"rank": { "type": "number", "minimum": 0, "maximum": 100 },
|
|
68
|
+
"traits": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"additionalProperties": { "type": "number", "minimum": 0, "maximum": 1 }
|
|
71
|
+
},
|
|
72
|
+
"capabilities": { "type": "array", "items": { "type": "string" } },
|
|
73
|
+
"constraints": { "type": "array", "items": { "type": "string" } },
|
|
74
|
+
"metadata": { "type": "object" }
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"relationship": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"required": ["from", "to", "type"],
|
|
80
|
+
"properties": {
|
|
81
|
+
"from": { "type": "string" },
|
|
82
|
+
"to": { "type": "string" },
|
|
83
|
+
"type": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"enum": ["superior", "subordinate", "peer", "competitive", "reviewer", "advisor", "ally", "rival", "mentor", "delegate"]
|
|
86
|
+
},
|
|
87
|
+
"weight": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
88
|
+
"mutable": { "type": "boolean" },
|
|
89
|
+
"metadata": { "type": "object" }
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"protocol": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"required": ["name", "description", "states", "transitions"],
|
|
95
|
+
"properties": {
|
|
96
|
+
"name": { "type": "string" },
|
|
97
|
+
"description": { "type": "string" },
|
|
98
|
+
"states": {
|
|
99
|
+
"type": "array",
|
|
100
|
+
"minItems": 1,
|
|
101
|
+
"items": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"required": ["name", "label"],
|
|
104
|
+
"properties": {
|
|
105
|
+
"name": { "type": "string" },
|
|
106
|
+
"label": { "type": "string" },
|
|
107
|
+
"owner": { "type": "string" },
|
|
108
|
+
"terminal": { "type": "boolean" },
|
|
109
|
+
"timeout": { "type": "number" },
|
|
110
|
+
"icon": { "type": "string" }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"transitions": {
|
|
115
|
+
"type": "array",
|
|
116
|
+
"items": {
|
|
117
|
+
"type": "object",
|
|
118
|
+
"required": ["from", "to"],
|
|
119
|
+
"properties": {
|
|
120
|
+
"from": { "type": "string" },
|
|
121
|
+
"to": { "type": "string" },
|
|
122
|
+
"guard": { "type": "string" },
|
|
123
|
+
"action": { "type": "string" },
|
|
124
|
+
"requiredRole": { "type": "string" },
|
|
125
|
+
"label": { "type": "string" }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"roles": {
|
|
130
|
+
"type": "object",
|
|
131
|
+
"additionalProperties": {
|
|
132
|
+
"type": "array",
|
|
133
|
+
"items": { "type": "string" }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"governance": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"required": ["decisionModel", "permissionMatrix", "reviewPolicy"],
|
|
141
|
+
"properties": {
|
|
142
|
+
"decisionModel": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"enum": ["autocratic", "democratic", "consensus", "meritocratic"]
|
|
145
|
+
},
|
|
146
|
+
"permissionMatrix": {
|
|
147
|
+
"type": "array",
|
|
148
|
+
"items": {
|
|
149
|
+
"type": "object",
|
|
150
|
+
"required": ["actor", "target", "actions"],
|
|
151
|
+
"properties": {
|
|
152
|
+
"actor": { "type": "string" },
|
|
153
|
+
"target": { "type": "string" },
|
|
154
|
+
"actions": {
|
|
155
|
+
"type": "array",
|
|
156
|
+
"items": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"enum": ["call", "assign", "review", "approve", "reject", "promote", "demote", "suspend", "eliminate", "allocate"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"reviewPolicy": {
|
|
165
|
+
"type": "object",
|
|
166
|
+
"required": ["mandatory", "reviewers", "maxRounds"],
|
|
167
|
+
"properties": {
|
|
168
|
+
"mandatory": { "type": "boolean" },
|
|
169
|
+
"reviewers": { "type": "array", "items": { "type": "string" } },
|
|
170
|
+
"maxRounds": { "type": "number", "minimum": 1 },
|
|
171
|
+
"autoApproveAfter": { "type": "number" }
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"escalationRules": {
|
|
175
|
+
"type": "array",
|
|
176
|
+
"items": {
|
|
177
|
+
"type": "object",
|
|
178
|
+
"required": ["trigger", "escalateTo", "action"],
|
|
179
|
+
"properties": {
|
|
180
|
+
"trigger": { "type": "string" },
|
|
181
|
+
"escalateTo": { "type": "string" },
|
|
182
|
+
"action": { "type": "string", "enum": ["notify", "reassign", "override", "cancel"] },
|
|
183
|
+
"timeoutMs": { "type": "number" }
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"resource": {
|
|
190
|
+
"type": "object",
|
|
191
|
+
"required": ["name", "type", "total", "distribution"],
|
|
192
|
+
"properties": {
|
|
193
|
+
"name": { "type": "string" },
|
|
194
|
+
"type": { "type": "string", "enum": ["finite", "renewable", "positional"] },
|
|
195
|
+
"total": { "type": "number", "minimum": 0 },
|
|
196
|
+
"distribution": { "type": "string", "enum": ["equal", "merit", "hierarchy", "competitive"] },
|
|
197
|
+
"refreshInterval": { "type": "number" },
|
|
198
|
+
"decayRate": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
199
|
+
"description": { "type": "string" }
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
"evolution": {
|
|
203
|
+
"type": "object",
|
|
204
|
+
"required": ["performanceWindow", "promotionThreshold", "demotionThreshold", "memoryRetention"],
|
|
205
|
+
"properties": {
|
|
206
|
+
"performanceWindow": { "type": "number", "minimum": 1 },
|
|
207
|
+
"promotionThreshold": { "type": "number", "minimum": 0, "maximum": 100 },
|
|
208
|
+
"demotionThreshold": { "type": "number", "minimum": 0, "maximum": 100 },
|
|
209
|
+
"memoryRetention": { "type": "number", "minimum": 1 },
|
|
210
|
+
"evolutionInterval": { "type": "number" }
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spec Compiler — transforms a parsed YAML spec into a live Universe.
|
|
3
|
+
*/
|
|
4
|
+
import type { UniverseConfig } from '../types/index.js';
|
|
5
|
+
import { Universe } from '../core/universe.js';
|
|
6
|
+
export interface CompileOptions {
|
|
7
|
+
/** Skip validation (for trusted specs) */
|
|
8
|
+
skipValidation?: boolean;
|
|
9
|
+
/** Auto-initialize the universe after compilation */
|
|
10
|
+
autoInit?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compile a UniverseConfig into a live Universe instance.
|
|
14
|
+
*/
|
|
15
|
+
export declare function compileUniverse(config: UniverseConfig, options?: CompileOptions): Promise<Universe>;
|
|
16
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/spec/compiler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,QAAQ,CAAC,CAmBnB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spec Compiler — transforms a parsed YAML spec into a live Universe.
|
|
3
|
+
*/
|
|
4
|
+
import { Universe } from '../core/universe.js';
|
|
5
|
+
import { validateSpec } from './validator.js';
|
|
6
|
+
/**
|
|
7
|
+
* Compile a UniverseConfig into a live Universe instance.
|
|
8
|
+
*/
|
|
9
|
+
export async function compileUniverse(config, options = {}) {
|
|
10
|
+
// Validate unless explicitly skipped
|
|
11
|
+
if (!options.skipValidation) {
|
|
12
|
+
const result = validateSpec(config);
|
|
13
|
+
if (!result.valid) {
|
|
14
|
+
const errorMsg = result.errors
|
|
15
|
+
.map(e => ` ${e.path}: ${e.message}`)
|
|
16
|
+
.join('\n');
|
|
17
|
+
throw new Error(`Universe spec validation failed:\n${errorMsg}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const universe = new Universe(config);
|
|
21
|
+
if (options.autoInit) {
|
|
22
|
+
await universe.initialize();
|
|
23
|
+
}
|
|
24
|
+
return universe;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/spec/compiler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS9C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAsB,EACtB,UAA0B,EAAE;IAE5B,qCAAqC;IACrC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM;iBAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;iBACrC,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,qCAAqC,QAAQ,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEtC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spec/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/spec/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UniverseConfig } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a YAML universe spec file into a typed UniverseConfig object.
|
|
4
|
+
* Does NOT validate — call validator separately for schema checking.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseSpecFile(filePath: string): UniverseConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Parse a YAML string into a UniverseConfig.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseSpecString(yamlContent: string): UniverseConfig;
|
|
11
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/spec/parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAG9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAwBnE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { parse as parseYaml } from 'yaml';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
/**
|
|
4
|
+
* Parse a YAML universe spec file into a typed UniverseConfig object.
|
|
5
|
+
* Does NOT validate — call validator separately for schema checking.
|
|
6
|
+
*/
|
|
7
|
+
export function parseSpecFile(filePath) {
|
|
8
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
9
|
+
return parseSpecString(content);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse a YAML string into a UniverseConfig.
|
|
13
|
+
*/
|
|
14
|
+
export function parseSpecString(yamlContent) {
|
|
15
|
+
const raw = parseYaml(yamlContent);
|
|
16
|
+
if (!raw || typeof raw !== 'object') {
|
|
17
|
+
throw new Error('Invalid YAML: root must be an object');
|
|
18
|
+
}
|
|
19
|
+
// Normalize defaults
|
|
20
|
+
const config = {
|
|
21
|
+
name: raw.name,
|
|
22
|
+
version: raw.version ?? '0.1.0',
|
|
23
|
+
description: raw.description ?? '',
|
|
24
|
+
type: raw.type ?? 'hybrid',
|
|
25
|
+
ruler: raw.ruler ? normalizeRuler(raw.ruler) : undefined,
|
|
26
|
+
agents: normalizeAgents(raw.agents ?? []),
|
|
27
|
+
relationships: raw.relationships ?? [],
|
|
28
|
+
protocols: raw.protocols ?? [],
|
|
29
|
+
governance: normalizeGovernance(raw.governance ?? {}),
|
|
30
|
+
resources: raw.resources,
|
|
31
|
+
evolution: raw.evolution,
|
|
32
|
+
metadata: raw.metadata,
|
|
33
|
+
};
|
|
34
|
+
return config;
|
|
35
|
+
}
|
|
36
|
+
function normalizeRuler(raw) {
|
|
37
|
+
return {
|
|
38
|
+
title: raw.title,
|
|
39
|
+
description: raw.description,
|
|
40
|
+
permissions: raw.permissions ?? [],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function normalizeAgents(agents) {
|
|
44
|
+
return agents.map((raw) => {
|
|
45
|
+
const agent = raw;
|
|
46
|
+
return {
|
|
47
|
+
id: agent.id,
|
|
48
|
+
name: agent.name,
|
|
49
|
+
role: normalizeRole(agent.role),
|
|
50
|
+
rank: agent.rank,
|
|
51
|
+
traits: agent.traits,
|
|
52
|
+
capabilities: agent.capabilities,
|
|
53
|
+
constraints: agent.constraints,
|
|
54
|
+
metadata: agent.metadata,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function normalizeRole(role) {
|
|
59
|
+
if (!role) {
|
|
60
|
+
return { title: 'unknown', duties: [], permissions: [] };
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
title: role.title ?? 'unknown',
|
|
64
|
+
department: role.department,
|
|
65
|
+
duties: role.duties ?? [],
|
|
66
|
+
permissions: role.permissions ?? [],
|
|
67
|
+
soulTemplate: role.soulTemplate,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function normalizeGovernance(gov) {
|
|
71
|
+
return {
|
|
72
|
+
decisionModel: gov.decisionModel ?? 'autocratic',
|
|
73
|
+
permissionMatrix: gov.permissionMatrix ?? [],
|
|
74
|
+
reviewPolicy: normalizeReviewPolicy(gov.reviewPolicy),
|
|
75
|
+
escalationRules: gov.escalationRules ?? [],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function normalizeReviewPolicy(policy) {
|
|
79
|
+
if (!policy) {
|
|
80
|
+
return { mandatory: false, reviewers: [], maxRounds: 1 };
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
mandatory: policy.mandatory ?? false,
|
|
84
|
+
reviewers: policy.reviewers ?? [],
|
|
85
|
+
maxRounds: policy.maxRounds ?? 1,
|
|
86
|
+
autoApproveAfter: policy.autoApproveAfter,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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IACvD,OAAO;QACL,aAAa,EAAG,GAAG,CAAC,aAA+D,IAAI,YAAY;QACnG,gBAAgB,EAAG,GAAG,CAAC,gBAAqE,IAAI,EAAE;QAClG,YAAY,EAAE,qBAAqB,CAAC,GAAG,CAAC,YAAmD,CAAC;QAC5F,eAAe,EAAG,GAAG,CAAC,eAAmE,IAAI,EAAE;KAChG,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,MAA2C;IACxE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAC3D,CAAC;IACD,OAAO;QACL,SAAS,EAAG,MAAM,CAAC,SAAqB,IAAI,KAAK;QACjD,SAAS,EAAG,MAAM,CAAC,SAAsB,IAAI,EAAE;QAC/C,SAAS,EAAG,MAAM,CAAC,SAAoB,IAAI,CAAC;QAC5C,gBAAgB,EAAE,MAAM,CAAC,gBAAsC;KAChE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UniverseConfig } from '../types/index.js';
|
|
2
|
+
import { type ValidationResult } from '../schema/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validate a universe spec at two levels:
|
|
5
|
+
* 1. JSON Schema validation (structure)
|
|
6
|
+
* 2. Semantic validation (references, consistency)
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateSpec(config: UniverseConfig): ValidationResult;
|
|
9
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/spec/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAwB,KAAK,gBAAgB,EAAwB,MAAM,oBAAoB,CAAC;AAEvG;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAcrE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { validateUniverseSpec } from '../schema/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate a universe spec at two levels:
|
|
4
|
+
* 1. JSON Schema validation (structure)
|
|
5
|
+
* 2. Semantic validation (references, consistency)
|
|
6
|
+
*/
|
|
7
|
+
export function validateSpec(config) {
|
|
8
|
+
// Level 1: JSON Schema
|
|
9
|
+
const schemaResult = validateUniverseSpec(config);
|
|
10
|
+
if (!schemaResult.valid) {
|
|
11
|
+
return schemaResult;
|
|
12
|
+
}
|
|
13
|
+
// Level 2: Semantic validation
|
|
14
|
+
const semanticErrors = validateSemantics(config);
|
|
15
|
+
if (semanticErrors.length > 0) {
|
|
16
|
+
return { valid: false, errors: semanticErrors };
|
|
17
|
+
}
|
|
18
|
+
return { valid: true, errors: [] };
|
|
19
|
+
}
|
|
20
|
+
function validateSemantics(config) {
|
|
21
|
+
const errors = [];
|
|
22
|
+
const agentIds = new Set(config.agents.map(a => a.id));
|
|
23
|
+
// Check relationship references
|
|
24
|
+
for (const rel of config.relationships) {
|
|
25
|
+
if (!agentIds.has(rel.from)) {
|
|
26
|
+
errors.push({
|
|
27
|
+
path: `/relationships`,
|
|
28
|
+
message: `Relationship references unknown agent: "${rel.from}"`,
|
|
29
|
+
keyword: 'reference',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (!agentIds.has(rel.to)) {
|
|
33
|
+
errors.push({
|
|
34
|
+
path: `/relationships`,
|
|
35
|
+
message: `Relationship references unknown agent: "${rel.to}"`,
|
|
36
|
+
keyword: 'reference',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Check protocol state references in transitions
|
|
41
|
+
for (const protocol of config.protocols) {
|
|
42
|
+
const stateNames = new Set(protocol.states.map(s => s.name));
|
|
43
|
+
for (const transition of protocol.transitions) {
|
|
44
|
+
if (!stateNames.has(transition.from)) {
|
|
45
|
+
errors.push({
|
|
46
|
+
path: `/protocols/${protocol.name}/transitions`,
|
|
47
|
+
message: `Transition references unknown state: "${transition.from}"`,
|
|
48
|
+
keyword: 'reference',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (!stateNames.has(transition.to)) {
|
|
52
|
+
errors.push({
|
|
53
|
+
path: `/protocols/${protocol.name}/transitions`,
|
|
54
|
+
message: `Transition references unknown state: "${transition.to}"`,
|
|
55
|
+
keyword: 'reference',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Check that terminal states have no outgoing transitions
|
|
60
|
+
const terminalStates = new Set(protocol.states.filter(s => s.terminal).map(s => s.name));
|
|
61
|
+
for (const transition of protocol.transitions) {
|
|
62
|
+
if (terminalStates.has(transition.from)) {
|
|
63
|
+
errors.push({
|
|
64
|
+
path: `/protocols/${protocol.name}/transitions`,
|
|
65
|
+
message: `Terminal state "${transition.from}" has outgoing transition`,
|
|
66
|
+
keyword: 'terminal',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Check permission matrix references
|
|
72
|
+
for (const entry of config.governance.permissionMatrix) {
|
|
73
|
+
const validActors = new Set([...agentIds, ...config.agents.map(a => a.role.title)]);
|
|
74
|
+
if (!validActors.has(entry.actor)) {
|
|
75
|
+
errors.push({
|
|
76
|
+
path: `/governance/permissionMatrix`,
|
|
77
|
+
message: `Permission entry references unknown actor: "${entry.actor}"`,
|
|
78
|
+
keyword: 'reference',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (!validActors.has(entry.target)) {
|
|
82
|
+
errors.push({
|
|
83
|
+
path: `/governance/permissionMatrix`,
|
|
84
|
+
message: `Permission entry references unknown target: "${entry.target}"`,
|
|
85
|
+
keyword: 'reference',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Check unique agent IDs
|
|
90
|
+
const idCounts = new Map();
|
|
91
|
+
for (const agent of config.agents) {
|
|
92
|
+
idCounts.set(agent.id, (idCounts.get(agent.id) ?? 0) + 1);
|
|
93
|
+
}
|
|
94
|
+
for (const [id, count] of idCounts) {
|
|
95
|
+
if (count > 1) {
|
|
96
|
+
errors.push({
|
|
97
|
+
path: `/agents`,
|
|
98
|
+
message: `Duplicate agent ID: "${id}" (found ${count} times)`,
|
|
99
|
+
keyword: 'uniqueness',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return errors;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/spec/validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA+C,MAAM,oBAAoB,CAAC;AAEvG;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAsB;IACjD,uBAAuB;IACvB,MAAM,YAAY,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QACxB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,+BAA+B;IAC/B,MAAM,cAAc,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjD,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IAClD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACrC,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAsB;IAC/C,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAA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